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
mariogmgi2g
Frequent Visitor

Legend and secondary values

Hi, 

 

I am working in represent in the same visual the averages by day of different furnaces according the selected furnaces and tiem. I do this adding a legend to display de furnaces averages separately, but i want to add the aerage of all furnaces to the visual to compare them correctly. I have spent weeks trying to add that measure, when i add the legen desktop don`t let me add other fields tan the measure affected by the legend, both in Values and Secondary values. Honestly, i am hopeless, i have spent hours searching for other visuals, overlapping visuals, etc. I don´t know if you guys know any way to achieve this. 

Here you have some pictures of what i have know. The page have a comparison visual from market place, but it doesn`t work correctly for me since i can match the left and right y-axis since the measures represented in the visual change according to the selector "Representación" and change the scale a lot. Sorry for my bad english.   

mariogmgi2g_0-1616058948049.png

mariogmgi2g_1-1616059013565.png

 

 

Thank you very much. 

1 ACCEPTED SOLUTION

Oh, sorry @MFelix,. I was sick this days so i couldn't answer you.

But yeeess!! You've saved me, I'm so grateful. It really works with some modifications to adapt to my measures. Than you.

View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @mariogmgi2g ,

 

You cannot use legend and different meausres in the same meanig that in terms of visualization you can use more than one measure in your values (main and secondary) or you can use the legend, for this case I believe you have two options depending on the average you want.

 

If is only a simple average over the total values you can go to the Analitycs and add a average:

MFelix_0-1616068462494.png

 

If you want you average to be calculated per period then you need to do a different approach.

 

Create a new table with the all the furnaces and an additonal line for the average I assume you have a column wiht the furnace name so you can do something similar to this:

 

 

Furnaces = UNION(DISTINCT('Table'[Furnace]),{"Furnace Average"})

 

 

Now add the following measure:

 

Legend Value = 
SWITCH (
     SELECTEDVALUE ( Furnaces[Furnace] ) ,
    "Furnace Average", AVERAGE ( 'Table'[Tiume] ),
    CALCULATE (
        SUM ( 'Table'[Tiume] ),
        FILTER (
            ALLSELECTED(  'Table'[Furnace] ),
            'Table'[Furnace] in VALUES( Furnaces[Furnace] )
        )
    )
)

 

 

I don't know if you want only the selected furnaces (measure above) or all but if you want all furnaces in the average used the measure below:

 

 

Legend Value = 
SWITCH (
     SELECTEDVALUE ( Furnaces[Furnace] ) ,
    "Furnace Average", CALCULATE(AVERAGE ( 'Table'[Tiume] ), ALL('Table'[Furnace])),
    CALCULATE (
        SUM ( 'Table'[Tiume] ),
        FILTER (
            ALLSELECTED(  'Table'[Furnace] ),
            'Table'[Furnace] in VALUES( Furnaces[Furnace] )
        )
    )
)

 

 

Now just create you line chart with the following setup:

 

Axis:  Date

Legend: Furnace from the new table

Values: Measure Legend Value

As you can see below the line of the average is the one that has the markers

 

MFelix_1-1616070493241.png

 

MFelix_2-1616070523066.png

 

Be aware that this measure may need some changes if you hve more than one value per each furnace per day, you information was not clear so I assumed you have a value per day.

 

Also notice that the slicer is based on the furnace original columns so you average will alway be presented in the visualization.

 

See PBIX attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks @MFelix!!

 

It didn`t work for know, but i`m sure this is the correct way. 

I think i didn´t give you enough information. Each furnace have four variables: intensity, temperature, coking time and weight. Due to requests, i have to represent all of them with other data in the same page, hence the two line visuals have conditional display through one measure: if they select one option the visual will display, for example, the intensity, and with the other, the weight. The measure represented is the next 

 

intensidad = VAR LogicTest = 
COUNTROWS(DISTINCT(FILTER(ALLSELECTED('Selector Multiple2'[Representación]), 'Selector Multiple2'[Representación] = "Intensidad+Temperatura"))) = 1 
RETURN IF(LogicTest, AVERAGE(GB_Hornada[IntensidadDesh]),AVERAGE(GB_Hornada[PesoCarbon]))

 

Then, the values per furnace and the total average (the average of all furnaces, not only the selected ones), must be conditional. 

And Some rows have more values per day per furnace than one.

Anyway, as i said, i'm very grateful with your answer, thank you for all your effort. 

Finally, i would like to know how the measure you recomended me works. I don't understand it very well, and thats why i can't modify it correctly. 

 

Again, thank you for all the time spent. 

 

EDIT: i could resolve the correct display except for the average of all furnaces. I wrote the sentence:

"Furnace Average", CALCULATE(AVERAGE ( 'Table'[Tiume] ), ALL('Table'[Furnace]))

as

 "Furnace average", CALCULATE(AVERAGE(GB_Hornada[IntensidadDesh]), ALL(GB_Hornada[IdHorno]))

But it don't draw the verage. If a replace GB_Hornada[IdHorno] (the original tables's number of the furnace) by furnace[IdHorno] (the knew table), the average of all selected furnaces are represented, but it doesn't include the filtered furnaces. 

Hi @mariogmgi2g ,

 

If you are using a measure then you need to make some adjustments and use that measure instead of the use of the calculation, but looking at you edit I assume you had the issue solved.

 

Regarding the second step you mentioned if you want to have only the average of the selected furnaces you need to change your measure to:

 

 "Furnace average", CALCULATE(AVERAGE(GB_Hornada[IntensidadDesh]), ALLSELECTED(GB_Hornada[IdHorno]))

 

If this does not work can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Oh, sorry @MFelix,. I was sick this days so i couldn't answer you.

But yeeess!! You've saved me, I'm so grateful. It really works with some modifications to adapt to my measures. Than you.

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.