This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
I am generating the following table below which just displays week number, total for the week (sum of sales), and a measure for calculating 8-week Running Total:
My problem is that, when I add the Week Description column (which is just text column from data source), the 8-week running total is no longer returning the correct results and is just the same as Total for the Week:
My formula for the 8-week Running Total is below:
8wk_Total =
VAR LastWeek = MAX ( Query1[Week] )
VAR Last8Weeks = TOPN (8, FILTER ( ALL ( Query1[Week] ), Query1[Week] <= LastWeek ), Query1[Week], DESC)
RETURN
CALCULATE ( SUM ( Query1[Sales] ), Last8Weeks )
Why does this happen and how can I fix this?
Solved! Go to Solution.
Hi @lancea,
Try measure as:
8wk_Total =
VAR LastWeek = MAX ( Query1[Week] )
VAR Last8Weeks = TOPN (8, FILTER ( ALL ( Query1[Week] ), Query1[Week] <= LastWeek ), Query1[Week], DESC)
RETURN
CALCULATE ( SUM ( Query1[Sales] ), FILTER(ALL('Query1'),Query1[Week] IN Last8Weeks )
Here is the output:
If you still have some question, please don't hesitate to let me known.
Best Regards,
Link
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!
Hi @lancea,
Try measure as:
8wk_Total =
VAR LastWeek = MAX ( Query1[Week] )
VAR Last8Weeks = TOPN (8, FILTER ( ALL ( Query1[Week] ), Query1[Week] <= LastWeek ), Query1[Week], DESC)
RETURN
CALCULATE ( SUM ( Query1[Sales] ), FILTER(ALL('Query1'),Query1[Week] IN Last8Weeks )
Here is the output:
If you still have some question, please don't hesitate to let me known.
Best Regards,
Link
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!
8wk_Total =
VAR LastWeek =
MAX ( Query1[Week] )
VAR Last8Weeks =
TOPN (
8,
FILTER ( ALL ( Query1 ), Query1[Week] <= LastWeek ),
Query1[Week], DESC
)
RETURN
CALCULATE ( SUM ( Query1[Sales] ), Last8Weeks )
Unfortuantely, this returns same result as the 2nd image.
@lancea , In such case better to have separate week or date table, That will allow you to all or allselected of table then column
8wk_Total =
VAR LastWeek = MAX ( Query1[Week] )
VAR Last8Weeks = TOPN (8, FILTER ( ALL ( Week[Week] ), Query1[Week] <= LastWeek ), Query1[Week], DESC)
RETURN
CALCULATE ( SUM ( Query1[Sales] ), Last8Weeks )
Sorry, this does not work and returns error in the formula:
For reference, I created a Week_Table using the formula:
It works now but unfortunately, I still get the same results:
Here is my formula for 8wk_separate:
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 27 | |
| 25 | |
| 22 | |
| 20 | |
| 14 |
| User | Count |
|---|---|
| 51 | |
| 47 | |
| 23 | |
| 18 | |
| 18 |