Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a live connection to a "locked" dataset that sits on top of a SSAS model. so I can only create measures. I have a table that has a bunch of columns including CustomerID , ProductID and Date Purchased along with 20 other columns. I would like to rank by customerID, Product ID based on Date Purchased Descending. This would repeat for each customer & productID . I need this done by a calculated measure that must be compatible with Direct Query/ Live Connection.
here how I am picturing the ranking to apply (I'm not displaying this data like this on a visual/dashboard)
Ex :
CustomerID ProductID Date Purchased Rank
1234 1 1-1-2023 1
1234 1 1-1-2022 2
1234 2 1-1-2019 1
3456 1 1-1-2020 1
3456 1 1-1-2018 2
3456 6 1-1-2020 1
Solved! Go to Solution.
@memoalkatib1 please try below measure
Rankx = RANKX(FILTER(ALL('Table'),'Table'[CustomerID] = MAX('Table'[CustomerID]) && 'Table'[ProductID] = MAX('Table'[ProductID])),CALCULATE(MAX('Table'[Date Purchased])),,DESC)
Thanks @DAXDigger . but the syntax for the code has multiple errors. I also think based off reading the code it'sef that the rating does not repeat for each customer+Product ID. also are you able why you're using max function ?
@memoalkatib1 please try below measure
Rankx = RANKX(FILTER(ALL('Table'),'Table'[CustomerID] = MAX('Table'[CustomerID]) && 'Table'[ProductID] = MAX('Table'[ProductID])),CALCULATE(MAX('Table'[Date Purchased])),,DESC)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |