Forum Discussion
Calculating difference to previous row
- 4 years ago
Hi, daniel_kusmider
Try to create measures like below:SUM = SUM('Table'[Leads])ThisWeek = CALCULATE( [SUM], FILTER( ALLSELECTED('Table'), 'Table'[End of Week]=MAX('Table'[End of Week]) ) )LastWeek = CALCULATE( [SUM], FILTER( ALLSELECTED('Table'), 'Table'[End of Week]=MAX('Table'[End of Week])-7 ) )LeadDiff% = DIVIDE( [ThisWeek]-[LastWeek], [LastWeek] )Result:
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
daniel_kusmider , You need to create a date table with weekend date and try measure like given below .
new columns in date /week table
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format
measures
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
- daniel_kusmider4 years agoNew Member
Thanks amitchandak,
That's a step forward 😉
To what you said I added one measure:
% Leads Diff = IFERROR((Leads[This Week] - Leads[Last Week])/Leads[Last Week], blank())and this one I showed in a table next to summarized Leads quantity:Now the question is how to make it interactive with slicers filtering the table.
As you can see below when I use any filters/slicers percentage values make no sence because they are calculated based on a total value for that week:
- Ashish_Mathur4 years agoSuper User
Hi,
Share the link from where i can download your PBI file. Clearly show the problem there.