Forum Discussion
I'm still trying to write a code that will give me a column (Position) showing 1-20
- 8 months ago
Hi Fedup,
This usually happens when row context isn’t defined.
To generate a 1–20 position column, use a ranking based on a stable sort column, for example:Use RANKX over the table, not a standalone list.
Key point: make sure you rank by a unique or ordered column (like Date or ID), otherwise Power BI may repeat the same number (like all 17).
Helpful sources:
RANKX function (DAX): https://learn.microsoft.com/dax/rankx-function-dax
Row vs filter context explained: https://learn.microsoft.com/dax/dax-overview#row-context
Calculated columns in Power BI: https://learn.microsoft.com/power-bi/transform-model/desktop-calculated-columns
Microsoft Learn (recommended):
Work with DAX ranking functions: https://learn.microsoft.com/training/modules/dax-power-bi-time-intelligence/
Savio Ferraz | Microsoft Learning Consulting | Google Certified Trainer and Microsoft Certified Educator
Did my answer help? Mark my post as a solution or like it if you found it useful.
Hi Fedup,
This usually happens when row context isn’t defined.
To generate a 1–20 position column, use a ranking based on a stable sort column, for example:
Use RANKX over the table, not a standalone list.
Key point: make sure you rank by a unique or ordered column (like Date or ID), otherwise Power BI may repeat the same number (like all 17).
Helpful sources:
RANKX function (DAX): https://learn.microsoft.com/dax/rankx-function-dax
Row vs filter context explained: https://learn.microsoft.com/dax/dax-overview#row-context
Calculated columns in Power BI: https://learn.microsoft.com/power-bi/transform-model/desktop-calculated-columns
Microsoft Learn (recommended):
Work with DAX ranking functions: https://learn.microsoft.com/training/modules/dax-power-bi-time-intelligence/
Savio Ferraz | Microsoft Learning Consulting | Google Certified Trainer and Microsoft Certified Educator
Did my answer help? Mark my post as a solution or like it if you found it useful.