Forum Discussion
Ranking on calculated measure
hi, GrahamR99
try to make new column
Column = RANK( DENSE, ALLSELECTED( 'Table (2)'[Sup Postcode], 'Table (2)'[Distance (km)] ), ORDERBY('Table (2)'[Distance (km)],ASC) ,,PARTITIONBY('Table (2)'[Sup Postcode]) )if you want to measure then try below code
Measure 2 = var a = ALL('Table (2)'[Distance (km)],'Table (2)'[Sup Postcode]) return RANK( DENSE, a, ORDERBY( 'Table (2)'[Distance (km)], ASC ),, PARTITIONBY('Table (2)'[Sup Postcode]) )Hello Dangar332
Thank you for the formula, it worked when I change the data.
When I first setup the Power BI report, I used Power BI mesure to calculate the distance between two locations. When I recreated the data in SQL Server and used it's ablity to calulate the distance, the data was a column and I could use your formula and also slice the distance column in my Power BI report which I could not do when it was a mesure.
The SQL Script I used was;
DistanceInMiles = GEOGRAPHY::Point([Lat], [Long], 4326).STDistance(GEOGRAPHY::Point([latitude], [longitude], 4326)) / 1609.344
Your formula I used was.
Column = RANK( DENSE, ALLSELECTED( 'Table (2)'[Sup Postcode], 'Table (2)'[Distance (km)] ), ORDERBY('Table (2)'[Distance (km)],ASC) ,,PARTITIONBY('Table (2)'[Sup Postcode]) )Thank you for your help.
Regards
GrahamR99
20 Replies
- 123abcCommunity Champion
You can try this modified Dax funciton:
Distance (Rank) =
RANKX(
FILTER(
'Legacy Events Planning 2024',
'Legacy Events Planning 2024'[Supporter_Postcode] = EARLIER('Legacy Events Planning 2024'[Supporter_Postcode])
),
CALCULATE('Legacy Events Planning 2024'[Distance (km)]),
,
ASC,
Dense
)In this modified formula, I replaced 'Legacy Events Planning 2024'[Distance (km)] with CALCULATE('Legacy Events Planning 2024'[Distance (km)]). This can help break the circular dependency, as CALCULATE allows you to create a context transition and evaluate the measure in a different context.
Try this modification and see if it resolves the circular dependency issue. If you encounter any further issues or if you have additional requirements, feel free to provide more details.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
- 123abcCommunity Champion
Plz use this modified DAX:
Distance (Rank) =
RANKX(
FILTER(
'Legacy Events Planning 2024',
'Legacy Events Planning 2024'[Supporter_Postcode] = EARLIER('Legacy Events Planning 2024'[Supporter_Postcode])
),
CALCULATE(
SUM('Legacy Events Planning 2024'[Distance (km)]),
ALLEXCEPT('Legacy Events Planning 2024', 'Legacy Events Planning 2024'[Supporter_Postcode])
),
,
ASC,
Dense
)if not work please sahre Pbxi file or excel file with sample data.