Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi All..
I want to return the last week value per category. Here are the data and the example:
WeekNo | Value | Category |
1 | 1 | A |
2 | 2 | A |
3 | 1 | A |
1 | 2 | B |
3 | 1 | B |
I want to create a table that shows the selected week value and the n-1 selected week value. I'm currently using this measure:
LastWeekValue = calculate( sum('table'[Value]), FILTER(ALL('table'), 'table'[WeekNo]= SELECTEDVALUE('table'[WeekNo]) - 1))
And here's the result of the measure:
Assuming that the selected week no is 3
Category | SelectedWeekValue | LastSelectedWeekValue |
A | 1 | 2 |
B | 1 | 2 |
The measure is showing the right sum of value on previous week. However, the value is showing the same value on each category. (Category B shows value = 2, eventhough that it actually has no value on week 2).
Here's the desired output looks like :
Assuming that the selected week no is 3
Category | SelectedWeekValue (week no 3) | LastSelectedWeekValue (week no 2) |
A | 1 | 2 |
B | 1 | 0 |
Please help me to solve this.
Thank you so much!!!!!
Solved! Go to Solution.
Hi @NKBI2022 ,
Please try like:
LastWeekValue =
VAR _lastweek = SELECTEDVALUE('Table'[WeekNo]) - 1
VAR _last_week_value = CALCULATE(SUM('Table'[Value]),'Table'[WeekNo]=_lastweek) + 0
RETURN
_last_week_value
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi @NKBI2022 ,
Please try like:
LastWeekValue =
VAR _lastweek = SELECTEDVALUE('Table'[WeekNo]) - 1
VAR _last_week_value = CALCULATE(SUM('Table'[Value]),'Table'[WeekNo]=_lastweek) + 0
RETURN
_last_week_value
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |