Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
User | Count |
---|---|
86 | |
85 | |
68 | |
67 | |
63 |
User | Count |
---|---|
210 | |
118 | |
116 | |
81 | |
74 |