Anonymous
2 years agoNot applicable
Switch between 'Year to Date' and 'Week to Date'
Hello, There is a between Date slicer on the report with several other slicers and charts. Here the requirement is user should be able to toggle between ‘Year To Date’ and ‘Week to Date’. The defaul...
- Anonymous2 years ago
Hi Anonymous ,
According to your statement, I think you want to calculate the number of previous week and the number of 2nd previous week based on the last date in your slicer.
Here I suggest you to try code as below. My Sample is easy a Data table with two columns [Date] and [Number] and a Calendar Table with date from 2023/08/28 to today.
Previous Month Number = VAR _MAXDATE = MAX('Calendar'[Date]) VAR _PREVIOUSWEEKEND = _MAXDATE - WEEKDAY(_MAXDATE,2) VAR _PREVIOUSWEEKSTART = _PREVIOUSWEEKEND - 6 RETURN CALCULATE(SUM('Table'[Number]),FILTER(ALL('Calendar'),'Calendar'[Date]>=_PREVIOUSWEEKSTART && 'Calendar'[Date]<=_PREVIOUSWEEKEND))2nd Previous Month Number = VAR _MAXDATE = MAX('Calendar'[Date]) VAR _PREVIOUSWEEKEND = _MAXDATE - WEEKDAY(_MAXDATE,2) VAR _2NDPREVIOUSWEEKEND = _PREVIOUSWEEKEND - 7 VAR _2NDPREVIOUSSTART = _2NDPREVIOUSWEEKEND - 6 RETURN CALCULATE(SUM('Table'[Number]),FILTER(ALL('Calendar'),'Calendar'[Date]>=_2NDPREVIOUSSTART && 'Calendar'[Date]<=_2NDPREVIOUSWEEKEND))Difference = [Previous Month Number] - [2nd Previous Month Number]Difference% = DIVIDE([Difference],[2nd Previous Month Number])Result is as below.
If this reply still couldn't help you solve your issue, please share a sample file with us.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.