Forum Discussion
Adding Weekday average line into stacked column chart
- 4 years ago
Hi chili ,
According to your description, does the following test result meet your requirements.
M = VAR cur_ = SELECTEDVALUE ( 'Table'[value] ) VAR day1 = CALCULATE ( MAX ( 'Table'[value] ), 'Table'[Date] - 7 = cur_ ) VAR day2 = CALCULATE ( MAX ( 'Table'[value] ), 'Table'[Date] - 14 = cur_ ) VAR day3 = CALCULATE ( MAX ( 'Table'[value] ), 'Table'[Date] = cur_ ) RETURN ( day1 + day2 + day3 ) / 3
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - 4 years ago
Hello, sorry for the late reply, I was testing out different solutions, but unfortunately the measure above cannot return the correct average number each weekday. I made few changes which inspired by your solution, and I finally got the right numbers for that:
First I created two measures:
1_week before sum =
VAR __max = MAX('Table'[date])
RETURN
calculate(SUMX('Table', 'Table'[value]),'Table'[date]=__max-7)and
2_week before sum =
VAR __max = MAX('Table'[date])
RETURN
calculate(SUMX('Table', 'Table'[value]),'Table'[date]=__max-14)
then I simply get the average by creating the third measure2 weeks average = ([1_week before sum] + [2_week before sum]/ 2
Finally, I used 2 weeks' average to be the value in the constant line, like what you did before. That's how I got the weekday average. Thanks again for your help!
Hi chili ,
According to your description, does the following test result meet your requirements.
M =
VAR cur_ =
SELECTEDVALUE ( 'Table'[value] )
VAR day1 =
CALCULATE ( MAX ( 'Table'[value] ), 'Table'[Date] - 7 = cur_ )
VAR day2 =
CALCULATE ( MAX ( 'Table'[value] ), 'Table'[Date] - 14 = cur_ )
VAR day3 =
CALCULATE ( MAX ( 'Table'[value] ), 'Table'[Date] = cur_ )
RETURN
( day1 + day2 + day3 ) / 3
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello, sorry for the late reply, I was testing out different solutions, but unfortunately the measure above cannot return the correct average number each weekday. I made few changes which inspired by your solution, and I finally got the right numbers for that:
First I created two measures:
1_week before sum =
VAR __max = MAX('Table'[date])
RETURN
calculate(SUMX('Table', 'Table'[value]),'Table'[date]=__max-7)
and
2_week before sum =
VAR __max = MAX('Table'[date])
RETURN
calculate(SUMX('Table', 'Table'[value]),'Table'[date]=__max-14)
then I simply get the average by creating the third measure
2 weeks average = ([1_week before sum] + [2_week before sum]/ 2
Finally, I used 2 weeks' average to be the value in the constant line, like what you did before. That's how I got the weekday average. Thanks again for your help!