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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Junminkim0214
Frequent Visitor

Use measure as chart legend

Hello Power BI super heroes!

 

I'd like to use 'Retail Excess' measure as a legend for a chart, but having trouble with it. May I know how I can make it?

I tried to find solutions from articles in ommunity, but couldn't.

 

Measures

Retail WOC = [CY RCS (qty)]/[Avg CS Last 4 Weeks]
Retail Excess = if([Retail WOC]>=12,"Excess","Non-Excess")
 
Value
Retail Closing Stock 
 
 
1 ACCEPTED SOLUTION

hi  @Junminkim0214 

First, measure can be affected by filter/slicer, so you can use it to get dynamic summary result in a visual by its row context. So you could not put it into Legend of a visual.

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

Second, for your case, you could this way as below:

Step1:

You need a table that contains all the result of this measure, for example:

5.JPG

 

Step2:

Create a measure like this logic:

Measure 3 = var _table=FILTER(CROSSJOIN(ADDCOLUMNS('Fact',"_type",[Measure]),'Type'),[_type]=[Type]) return
COUNTROWS(_table)

 

You could also use SUMX/MAXX/MINX instead of COUNTROWS in the formula

Result:

6.JPG7.JPG

 

here is sample pbix file, please try it.

 

Regards,

Lin

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

View solution in original post

4 REPLIES 4
Pragati11
Super User
Super User

HI @Junminkim0214 ,

 

You can never use a MEASURE as a legend in the charts. They have to be always COLUMNS.

Convert your measure as a calculated column, then use it as a legend in your chart.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi @Pragati11 

 

Thanks for your advice!

 

I created a column like below, but the results are not correct. May I know a reason for this?

 

Column

Retail Excess column = if([Retail WOC]>=12,"Excess","Non-Excess")

 

Measure

Retail Excess = if([Retail WOC]>=12,"Excess","Non-Excess")

 

Junminkim0214_0-1595248768261.png

 

Best regards,

 

Jun

hi  @Junminkim0214 

First, measure can be affected by filter/slicer, so you can use it to get dynamic summary result in a visual by its row context. So you could not put it into Legend of a visual.

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

Second, for your case, you could this way as below:

Step1:

You need a table that contains all the result of this measure, for example:

5.JPG

 

Step2:

Create a measure like this logic:

Measure 3 = var _table=FILTER(CROSSJOIN(ADDCOLUMNS('Fact',"_type",[Measure]),'Type'),[_type]=[Type]) return
COUNTROWS(_table)

 

You could also use SUMX/MAXX/MINX instead of COUNTROWS in the formula

Result:

6.JPG7.JPG

 

here is sample pbix file, please try it.

 

Regards,

Lin

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

Hi @Junminkim0214 ,

 

How is your following measure caluclated?

Retail WOC = [CY RCS (qty)]/[Avg CS Last 4 Weeks]

 

It uses 2 more measures, how are they calculated?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors