Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PriyankaJhaTheA
Helper III
Helper III

URGENT!! Convert Measure to Calculated Column

Hello Power BI community!

 

Need some urgent help in converting the following measure to a calculated column. The min purpose is that I can use this new column as a legend for my pie chart. 

 

Ranking SingleSelect = 
RANKX(ALLSELECTED('df_Search Order (First)'[Search Order (First)]), [Category_Occasion_SingleSelect%], , DESC, Dense)

 @MFelix , @amitchandak , @Ashish_Mathur 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @PriyankaJhaTheA 

Thank you very much for your reply. Here's how I handle ranking with measure in calculated columns:
1. First of all, use the summarize function to summarize the measure, here I simply create a measure as shown in the following photos:

vjianpengmsft_0-1710148323457.png

I use the following DAX to call this measure and generate a calculation table:

Table =
SUMMARIZE (
    'df_Search Order (First)',
    'df_Search Order (First)'[Search Order (First)],
    "result", [category_Occasion_%]
)

Here are the results:

vjianpengmsft_1-1710148456972.png

You need to replace [category_Occasion_%] with your measure.

2. Create a connection for the two tables:

vjianpengmsft_2-1710148553546.png

3.The following DAX is used for ranking in the original table:

Ranking SingleSelect =
RANKX ( 'df_Search Order (First)', RELATED ( 'Table'[result] ),, DESC, SKIP )

Here are the results:

vjianpengmsft_3-1710148695587.png

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi, @PriyankaJhaTheA 

Based on your DAX, I used the following sample data:

vjianpengmsft_0-1710136446352.png

I'm using the following DAX expression in the calculated column for ranking:

Ranking SingleSelect =
RANKX (
    'df_Search Order (First)',
    [Category_Occasion_SingleSelect%],
    ,
    DESC,
    DENSE
)

Here are the results:

vjianpengmsft_2-1710136572246.png

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hello @Anonymous 

 

Thanks for helping here!

But I'm getting this error here when I run this code. This might be because [Category_Occasion_SingleSelect%] is a measure. Can there be another way? 

Also, I'm trying to convert this into a column because I want to use this as a legend in my pie chart. But I cannot add a measure as a legend.

 

PriyankaJhaTheA_1-1710139324996.png

 

Anonymous
Not applicable

Hi, @PriyankaJhaTheA 

Thank you very much for your reply. Here's how I handle ranking with measure in calculated columns:
1. First of all, use the summarize function to summarize the measure, here I simply create a measure as shown in the following photos:

vjianpengmsft_0-1710148323457.png

I use the following DAX to call this measure and generate a calculation table:

Table =
SUMMARIZE (
    'df_Search Order (First)',
    'df_Search Order (First)'[Search Order (First)],
    "result", [category_Occasion_%]
)

Here are the results:

vjianpengmsft_1-1710148456972.png

You need to replace [category_Occasion_%] with your measure.

2. Create a connection for the two tables:

vjianpengmsft_2-1710148553546.png

3.The following DAX is used for ranking in the original table:

Ranking SingleSelect =
RANKX ( 'df_Search Order (First)', RELATED ( 'Table'[result] ),, DESC, SKIP )

Here are the results:

vjianpengmsft_3-1710148695587.png

 

 

Sahir_Maharaj
Super User
Super User

Hello @PriyankaJhaTheA,

 

Can you please try the following: 

Ranking SingleSelect = 
RANKX(
    ALL('df_Search Order (First)'), 
    CALCULATE(SUM('df_Search Order (First)'[Category_Occasion_SingleSelect%])), 
    , 
    DESC, 
    Dense
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hello @Sahir_Maharaj 

 

Thanks for helping here!

But I'm getting this error here when I run this code. This might be because [Category_Occasion_SingleSelect%] is a measure. Can there be another way? 

Also, I'm trying to convert this into a column because I want to use this as a legend in my pie chart. But I cannot add a measure as a legend.

 

PriyankaJhaTheA_2-1710139530407.png

 

 

lbendlin
Super User
Super User

This here is a forum where users help users, time permitting.  For urgent requests contact a Microsoft partner near you.

 

Please provide a more detailed explanation of what you are aiming to achieve. What have you tried and where are you stuck?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.