Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
@gopichilla wrote:
Hi All,
I want previous week sales anyone can send me DAX query.
Thanks
You'll need a calendar table as below.
calendar = VAR TEMPTBL = ADDCOLUMNS ( CALENDAR ( "2016-12-31", "2017-12-31" ), "Year", YEAR ( [Date] ), "weekNo", WEEKNUM ( [Date] ), "YearWeek", CONCATENATE ( YEAR ( [Date] ), RIGHT ( CONCATENATE ( "0", WEEKNUM ( [Date] ) ), 2 ) ) ) RETURN ADDCOLUMNS ( TEMPTBL, "WeekIndex", RANKX ( TEMPTBL, [YearWeek],, ASC, DENSE ) )
Then create a one to many relationship from calendar table to data table. Then use a measure as below to get the previous week's value.
previous week value = CALCULATE ( SUM ( data[value] ), FILTER ( ALLSELECTED ( 'calendar' ), MAX ( 'calendar'[WeekIndex] ) = 'calendar'[WeekIndex] + 1 ) )
See more details in the attached pbix file.
@gopichilla wrote:
Hi All,
I want previous week sales anyone can send me DAX query.
Thanks
You'll need a calendar table as below.
calendar = VAR TEMPTBL = ADDCOLUMNS ( CALENDAR ( "2016-12-31", "2017-12-31" ), "Year", YEAR ( [Date] ), "weekNo", WEEKNUM ( [Date] ), "YearWeek", CONCATENATE ( YEAR ( [Date] ), RIGHT ( CONCATENATE ( "0", WEEKNUM ( [Date] ) ), 2 ) ) ) RETURN ADDCOLUMNS ( TEMPTBL, "WeekIndex", RANKX ( TEMPTBL, [YearWeek],, ASC, DENSE ) )
Then create a one to many relationship from calendar table to data table. Then use a measure as below to get the previous week's value.
previous week value = CALCULATE ( SUM ( data[value] ), FILTER ( ALLSELECTED ( 'calendar' ), MAX ( 'calendar'[WeekIndex] ) = 'calendar'[WeekIndex] + 1 ) )
See more details in the attached pbix file.
I wonder why its not working for me
Hi @ApurvaKhatri,
Share more details. Share your dataset and show the expected result.
C
Hello @Ashish_Mathur
Curent Sum is a measure.
I need the difference of Oct 25 and Oct 18 to be displayed in another column.Similarly Oct 18 - oct 11 i.e 87 - 80 so 4 should be displayed. Like wise for all the value differences
Hi,
Share the link from where i can download your file.
Thanks it is working fine.
User | Count |
---|---|
93 | |
83 | |
77 | |
71 | |
65 |
User | Count |
---|---|
114 | |
101 | |
96 | |
65 | |
60 |