Forum Discussion
Weekly % Change DAX Formula Help
- Anonymous2 years ago
Hi ll0606 ,
Based on my testing, please try the following methods:
1.Create the sample table.
2.Create the measure to calculate the change between the previous week and current week.
weekly change = var date_ = SELECTEDVALUE('Table'[Date]) VAR current_sum = CALCULATE ( SUM ( 'Table'[Number]), FILTER(ALL('Table'), 'Table'[Date] = date_) ) VAR sum_preWeek = CALCULATE ( SUM ( 'Table'[Number]), FILTER(ALL('Table'), 'Table'[Date] = date_ - 7) ) VAR min_week = CALCULATE(MIN('Table'[Date]), ALLSELECTED('Table'[Date])) RETURN IF(date_ = min_week, BLANK(), DIVIDE((current_sum - sum_preWeek ), sum_preWeek))3.Drag the measure into the matrix visual. Change the data Format.
4.The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi ll0606 ,
Based on my testing, please try the following methods:
1.Create the sample table.
2.Create the measure to calculate the change between the previous week and current week.
weekly change =
var date_ = SELECTEDVALUE('Table'[Date])
VAR current_sum =
CALCULATE (
SUM ( 'Table'[Number]),
FILTER(ALL('Table'), 'Table'[Date] = date_)
)
VAR sum_preWeek =
CALCULATE (
SUM ( 'Table'[Number]),
FILTER(ALL('Table'), 'Table'[Date] = date_ - 7)
)
VAR min_week =
CALCULATE(MIN('Table'[Date]), ALLSELECTED('Table'[Date]))
RETURN
IF(date_ = min_week, BLANK(), DIVIDE((current_sum - sum_preWeek ), sum_preWeek))
3.Drag the measure into the matrix visual. Change the data Format.
4.The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.