Forum Discussion
Data Table: Weekend Ending Column
- Anonymous6 years ago
Hi HenryJS ,
Can I know which formula used in calculated column "Calendar'[WeekDay]"? It should be just like below one:
Calendar'[WeekDay]=WEEKDAY(Calendar[Date],2)
Best Regards
Rena
Hi Greg_Deckler I need this for Columns in a Matrix.
It won't let me drag the mWeekEnding measure to columns for the matrix
- amitchandak6 years agoSuper User
You can create a week ending measure like
"Week No. 1 - WE 12/04"
Ending = "Week No. 1 - WE " & Format([Week End date],"DD/MM")
For Week end date refer this file
https://www.dropbox.com/s/a9xq913pgvuzg2x/sales_analytics_weekWiseMon_sun.pbix?dl=0
- Greg_Deckler6 years agoCommunity Champion
The column version is in the PBIX file attached to that post.
WeekEnding = VAR myWeekNum = WEEKNUM([Date]) VAR myYear = YEAR([Date]) VAR myEndDate = CALCULATE(MAX([Date]),FILTER(ALL(Calender),YEAR([Date])=myYear && Calender[WeekNum]=myWeekNum && Calender[WeekDay]=7)) VAR myEndDate1 = IF(NOT(ISBLANK(myEndDate)),myEndDate,CALCULATE(MAX([Date]),FILTER(ALL(Calender),YEAR([Date])=myYear+1 && Calender[WeekNum]=1&&Calender[WeekDay]=7))) VAR myEndDate2 = IF(NOT(ISBLANK(myEndDate1)),myEndDate1,MAX([Date])) RETURN "W" & myWeekNum & " Week Ending " & myEndDate2- HenryJS6 years agoPost Prodigy
Hi Greg_Deckler
Ok - I got the column version to work. When put into matrix columns the column headers don't follow the correct date order - please see below.
Is it also possible to change the date format to English dd/mm/yyyy?
- Greg_Deckler6 years agoCommunity Champion
Sure it's the last line:
WeekEnding = VAR myWeekNum = WEEKNUM([Date]) VAR myYear = YEAR([Date]) VAR myEndDate = CALCULATE(MAX([Date]),FILTER(ALL(Calender),YEAR([Date])=myYear && Calender[WeekNum]=myWeekNum && Calender[WeekDay]=7)) VAR myEndDate1 = IF(NOT(ISBLANK(myEndDate)),myEndDate,CALCULATE(MAX([Date]),FILTER(ALL(Calender),YEAR([Date])=myYear+1 && Calender[WeekNum]=1&&Calender[WeekDay]=7))) VAR myEndDate2 = IF(NOT(ISBLANK(myEndDate1)),myEndDate1,MAX([Date])) RETURN myEndDate2