Excel - commonly used for work

start date of the week

=TODAY()-WEEKDAY(TODAY(),2)-6

TODAY() represents the date of the current day, WEEKDAY(TODAY(),2) represents the day of the week, TODAY()-WEEKDAY(TODAY(),2) this formula calculates the last day of the previous week, -6 It became the first day of the previous week.

 

end date of the week

=TODAY()-WEEKDAY(TODAY(),2)

It is basically the same as the actual date, except that there is no need to subtract 6, because the previous formula just calculates the end date of the week.

 

The date of the current year represented by the above two functions, if you want to calculate the date of the previous year, you need to refer to the cells of the end and start date of the current year.

The formula for the week end date of the previous year is =YEAR(B3)-1&"-"&MONTH(B3)&"-"&DAY(B3), where B3 is the referenced cell (the week end date), which is equivalent to putting This year's end date of this week is reduced by 1, and the month and day remain unchanged.

The formula for the week start date of the previous year is =YEAR(B2)-1&"-"&MONTH(B2)&"-"&DAY(B2), the same as above, or a unit that directly refers to the week end date of the previous year grid and then subtract 6, the result is the same.

 

Through the above formulas, we have obtained 4 dates, which are the start and end dates of the current year, and the start and end dates of the previous year. If we write a date in a cell (that is, to Write a date range in a cell), we can use the following formula

=CUBESET("SYRetail","{[日期].[日期].&["&TEXT(B2,"yyyy-mm-dd")&"]:[日期].[日期].&["&TEXT(B3,"yyyy-mm-dd")&"]}",TEXT(B2,"YY.M.DD")&"-"&TEXT(B3,"M.DD"))

CUBESET means a section of the reference data source, here we want a date, SYRetail is the name of our data source, fixed, type the CUBESET function, type double quotes, the data source name will be automatically displayed,

"{ [date].[date] . &["&TEXT(B2,"yyyy-mm-dd")&"] :[date].[date].&["&TEXT(B3,"yyyy-mm-dd ")&"]}" This function means that I want to get the date, and then its date style and value are &["&TEXT(B2,"yyyy-mm-dd")&"], : means yes Meaning, it means that I want to take a date,: the previous one is the starting date,

The following date is the same as the previous one, except that the referenced cell is the end date ( B3 ) of the date you want to fetch, [date].[date].&["&TEXT( B3 ,"yyyy-mm -dd")&"]. Pay attention to the symbol of this whole function. First, you need to take the value of a section, then you must use a curly bracket {}, which is equivalent to an array, and then the linked date styles also appear in pairs.

&["& &"], where the TEXT function converts numbers into text, because the dates in the data source are all in the form of text, and the value cannot be retrieved without conversion. Now let's analyze the third parameter. The third parameter refers to the form in which the desired date range is presented. Similarly, because this date range will be directly quoted in the future, the date should be converted into text. The formula is TEXT(B2,"YY.M.DD")&"-"&TEXT(B3,"M.DD"), this formula is easy to understand, the only thing to pay attention to is the symbolic representation that distinguishes two dates in the middle, here Use - but add so many &"-"& between the two dates, pay attention here.

 

 

 

 

start date of the month

The formula is =EOMONTH(B3,-1)+1, B3 is the reference cell (referring to the end date of this week in this year), EOMONTH is the last day function before or after the specified date month, the second parameter It means that the last day of the previous month is the last day of the following month. For example, the date of the cell I want to reference is 2017-07-07, then if I write -1 in the second parameter, I will get 2017-06-30, if it is 1 will get 2017-08-31, and 2 will get 2017-09-30. And what we want to get is the start date of this month, then we quote the end date of this week, use it to get the last day of the previous month, and then add 1 to get this month start date of .

 

end of the month

The end date of this month can directly refer to the date of this week in this year, because we count every four weeks as a month! ! ! Otherwise, use the =TODAY() formula.

 

start date of the year

The start date of the year can be manually typed. Enter "2018-01-01" for this year and write "2017-01-01" for last year

 

end date of the year

The end date of the year refers to the end date of the month.

 

 

 

Call a condition in the data source (to put it bluntly, I want a cell to present the condition of the data source, so I can directly reference it when making a table, but the handwritten text and values ​​cannot be called when the cell refers to the condition, It will also report an error, so the value or text in the cell we want to reference must be substituted into the formula)

For example, to transfer a date, the formula =CUBEMEMBER("SYRetail","[date].[date].&["&TEXT(K4,"yyyy-MM-dd")&"]")

CUBEMEMBER means to call a certain condition, "SYRetail" is the data source, fixed format, "[date].[date].&["&TEXT(K4,"yyyy-MM-dd")&"]" is called Content, the first half [date].[date] represents the content of the data source, &["&TEXT(K4,"yyyy-MM-dd")&"] represents the style presented by the referenced condition.

 

 

Call the values ​​of multiple conditions in the data source (through the above formulas, we can now call some conditions from the data source, and the following function allows us to use these conditions to find the corresponding values, such as May in the self-operated area What is the sales amount from No. 1 to No. 5)

=CUBEVALUE("SYRetail",$F19,$B$7,$G$3), CUBEVALUE is a function that calls the values ​​of multiple conditions in the data source, the "SYRetail" data source name is in a fixed format, and the following parameters are the conditions to be quoted, Write several parameters if there are several conditions, and separate them with . Note that these conditions are and the relationship.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325852505&siteId=291194637