Forum Discussion
lancea
Helper I
5 years agoTopN returns different results when adding additional column
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...
- 5 years ago
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!
Jihwan_Kim
Super User
5 years ago8wk_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 )
lancea
Helper I
5 years agoUnfortuantely, this returns same result as the 2nd image.