Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
78 | |
40 | |
40 | |
35 |