Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello everyone,
I am having some trouble with filtering the top ranking category (by sales) for a specific time period. From previous tips on this forum, the top-ranking category for all sales can be found by:
Category Top =
VAR _A =
FILTER (
ADDCOLUMNS (
'Sales',
"Rank",
RANKX (
ALLSELECTED ( 'Sales'[Category] ),
CALCULATE ( SUM ( 'Sales'[Sales Amount] ) ),
,
DESC,
DENSE
)
),
[Rank] = 1
)
RETURN
MAXX ( _A, [Category] )
I am having trouble filtering this down for a specific time period (say 7 days). To attempt to tackle this, I have tried replacing:
CALCULATE ( SUM ( 'Sales'[Sales Amount] ) )
with
CALCULATE ( SUM ( 'Sales'[Sales Amount] ), DATESINPERIOD('Sales'[DATE], TODAY(), -7, DAY)
But this doesn't seem to produce the results I am looking for.
Any tips?
Solved! Go to Solution.
HI @Anonymous
Try this:
Category Top =
VAR _A =
FILTER (
ADDCOLUMNS (
'Sales',
"Rank",
RANKX (
'Sales',
CALCULATE (
SUM ( 'Sales'[Sales Amount] ),
DATESINPERIOD ( 'Sales'[DATE], TODAY (), -7, DAY )
),
,
DESC,
DENSE
)
),
[Rank] = 1
)
RETURN
MAXX ( _A, [Category] )
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Thanks VahidDM
HI @Anonymous
Try this:
Category Top =
VAR _A =
FILTER (
ADDCOLUMNS (
'Sales',
"Rank",
RANKX (
'Sales',
CALCULATE (
SUM ( 'Sales'[Sales Amount] ),
DATESINPERIOD ( 'Sales'[DATE], TODAY (), -7, DAY )
),
,
DESC,
DENSE
)
),
[Rank] = 1
)
RETURN
MAXX ( _A, [Category] )
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 14 | |
| 7 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 25 | |
| 10 | |
| 10 | |
| 6 | |
| 6 |