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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
lucamilanesi
Frequent Visitor

Using a text measure as a legend

Hello everyone,

 

I'd need your help: I created the measure "Measure_Level_Asset".

 

 Misura_Livello_Asset = IF(GOV_Asset[Misura_Rischio_Residuo_Asset]<1,"Azzurro",IF(GOV_Asset[Misura_Rischio_Residuo_Asset]<2,"Verde",IF(GOV_Asset[Misura_Rischio_Residuo_Asset]<3,"Giallo",IF(GOV_Asset[Misura_Rischio_Residuo_Asset]<5,"Arancione","Rosso"))))

 

the format is text type.

Unfortunately PBI does not allow me to use this measure in the legend fields of the various viewers (instograms for example).
I tried to convert the measurement into a calculated column but I make mistakes, in fact I display the error:

 

Error PBI.PNG

 

How can I reach a solution?

Thank you

1 ACCEPTED SOLUTION

Hi @lucamilanesi

 

You cannot create calculated column based on measures.This process may be a little complicated, but it can solve your problem.
1. Create a table with "Azzurro", "Verde", "arancione", "Rosso",Then you can use this column in the legend fields.
2.Create four separately measures for “ Azzurro” and “ Verde” and “ Arancione” and “ Rosso”. Add these two measures into Values section of the chart.
DAX is like this:

 

 

num_Azzurro = COUNTROWS(
		FILTER(ALL('GOV_Asset'),
			[Misura_Livello_Asset] = "Azzurro"
		)
	      )

num_selection = 
    var _nv = SELECTEDVALUE('Table'[Column1])
    return SWITCH(_nv,"Azzurro",[num_Azzurro])

You can refer to this .pbix.

 

 

Best Regards,
Liang
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

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @lucamilanesi ,

 

It is not possible to add a measure as chart legend, as measure actually returns a single value.

Based on your description, you have a trouble with creating calculated columns. Can you provide some sample data and the results you want?

 

Best Regards,

Liang

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

Misura_Livello_Asset.png

Thank you for your interest @V-lianl-msft 

This table is formed by the measure "Measure_Level_Asset", the content is the one in evidence (names of colors). Each asset is identified by a color (which may vary depending on the value assigned to the various parameters). In fact, this measure is dependent on another measure.
I hope I have provided useful information.

Hi @lucamilanesi

 

You cannot create calculated column based on measures.This process may be a little complicated, but it can solve your problem.
1. Create a table with "Azzurro", "Verde", "arancione", "Rosso",Then you can use this column in the legend fields.
2.Create four separately measures for “ Azzurro” and “ Verde” and “ Arancione” and “ Rosso”. Add these two measures into Values section of the chart.
DAX is like this:

 

 

num_Azzurro = COUNTROWS(
		FILTER(ALL('GOV_Asset'),
			[Misura_Livello_Asset] = "Azzurro"
		)
	      )

num_selection = 
    var _nv = SELECTEDVALUE('Table'[Column1])
    return SWITCH(_nv,"Azzurro",[num_Azzurro])

You can refer to this .pbix.

 

 

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

Capture2.PNGHi @V-lianl-msft ,

 

i think that we are not understanding each other or I am really far from understanding the solution (probably) 🙂

I created a dynamic report (by dynamic I mean that varying one or more parameters set get different results and then different views) to simulate different scenarios. Everything is built through calculated columns and measures referred to the parameters.

It works everything except the change of color in the display that I attach, I have to use the calculated field "Level_Asset" (which does not change to vary parameters, of course it is static in the simulation) as a legend and not the measure "Measure_Level_Asset" because of course the measure can not be entered as a legend for various reasons.

So how to do it? 🙂

Thank you very much

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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