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
Anonymous
Not applicable

Help with the graphic

Hi!

I am having a problem with the graphic of some datas.

First, I have the following table:

5.PNG

Where:

METAS1 = IF([MTTR DIC]>VALUE(META_MTTR[MTTR MAX]);"INEFICIENTE";IF([MTTR DIC]<VALUE([MTTR PROM]);"EXCEDE";IF(AND([MTTR DIC]<VALUE([MTTR MAX]);[MTTR DIC]>VALUE([MTTR PROM]));"CUMPLE META";"n/d")))
 
And the problem is than I can´t make any graphic with these datas except the table I show above, and I know the problem is with the measure  METAS1 and I don´t know why. (I am trying to make a Pie chart)
 
Do you have any suggestions?
 
Thanks
1 ACCEPTED SOLUTION

Ok, @Anonymous  I got your file. I did a little digging and now it makes sense to me. Measures return a single value, which depends on the filter context. You cannot use that in a legend. You have two options that I see:

 

  1. Create the field values in Power Query. That will be difficult because of the way the data is stored in other tables and will require joins.
  2. Create a calculated column. Your SWITCH measure will actually work there, but you'll need to test. You can drop that into a legend field of a Pie Chart.

Then create a measure you want in your values part of the chart. 

Test Value = COUNTROWS(META_MTTR) for example will count the number of records for each META and show the relevant percentages in the chart.

As a slight aside, if you will convert your [MTTR promedio (horas)] and [MTTR máx (horas)] to numbers in Power Query (the Tipo cambiado step) click the little ABC in the upper left corner of that column and change it to a number, then you can dispense with all of the VALUE() functions in your model.
 
Does that help? The issue is you really need to have most/all of your fields you want to slice and dice on coming in as fields from Power Query, and use measure to be the values. There are a lot of places measures cannot work. Slicers, filters, and as we've discovered, many parts of a lot of visuals, because measures return 1 value at calc. You see many in a table, but in reality, it is one value. It just recalculates the measure for that row of the table based on the filter context. It isn't returning a column of 4/5 values you can use as a true column.


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
edhans
Super User
Super User

A couple of things that might help.

First, consider using SWITCH instead of multiple nested IF statements. So

 

METAS1 =
IF(
    [MTTR DIC]
        > VALUE( META_MTTR[MTTR MAX] );
    "INEFICIENTE";
    IF(
        [MTTR DIC]
            < VALUE( [MTTR PROM] );
        "EXCEDE";
        IF(
            AND(
                [MTTR DIC]
                    < VALUE( [MTTR MAX] );
                [MTTR DIC]
                    > VALUE( [MTTR PROM] )
            );
            "CUMPLE META";
            "n/d"
        )
    )
)

 

Becomes:

 

 

METAS1 =
SWITCH(
    TRUE(),
    [MTTR DIC] > VALUE( META_MTTR[MTTR MAX] ), "INEFICIENTE",
    [MTTR DIC] < VALUE( [MTTR PROM] ), "EXCEDE",
    [MTTR DIC] < VALUE( [MTTR MAX] )
        && [MTTR DIC] > VALUE( [MTTR PROM] ), "CUMPLE META",
    "n/d"
)

 

 

Note I haven't validated that measure because I didn't have data I could copy and paste into Power BI.

 

It doesn't work in a Pie Chart though because there are no values. You need values to make a visual work, and you have two columns of text.

Create this measure in your table:

 

Data Account = COUNTROWS(TableName)

 

 

Now drop that value in the pie chart. Use the METAS1 measure as your legend for the chart.

This will just tell you the number of times each label in METAS1 shows up. You could use any measure that evaluates to a numerical value as your Value amount fo the visual.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hey @edhans 

Thanks!

I change the measure from "if" to "switch", and help a lot.

 

But, I can´t make the pie chart yet, although I created the "Data account" measure, I am trying to put METAS1 in the legend section but it still doesnt allow me to do it.

 

Do you have any idea?

I'd have to see your PBIX file or more info. It works fine for me.

 

2020-02-02 17_31_52-Untitled - Power BI Desktop.png

 

You can actually drag your METAS1 field to Values and tell Power BI to do a count, but that can cause problems later if you make any changes to how METAS1 works. Always best to do an explicit measure, even for something as simple as a row count.

 

Post a sample PBIX file if this isn't working for you. Use OneDrive or something similar to share.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Ok, @Anonymous  I got your file. I did a little digging and now it makes sense to me. Measures return a single value, which depends on the filter context. You cannot use that in a legend. You have two options that I see:

 

  1. Create the field values in Power Query. That will be difficult because of the way the data is stored in other tables and will require joins.
  2. Create a calculated column. Your SWITCH measure will actually work there, but you'll need to test. You can drop that into a legend field of a Pie Chart.

Then create a measure you want in your values part of the chart. 

Test Value = COUNTROWS(META_MTTR) for example will count the number of records for each META and show the relevant percentages in the chart.

As a slight aside, if you will convert your [MTTR promedio (horas)] and [MTTR máx (horas)] to numbers in Power Query (the Tipo cambiado step) click the little ABC in the upper left corner of that column and change it to a number, then you can dispense with all of the VALUE() functions in your model.
 
Does that help? The issue is you really need to have most/all of your fields you want to slice and dice on coming in as fields from Power Query, and use measure to be the values. There are a lot of places measures cannot work. Slicers, filters, and as we've discovered, many parts of a lot of visuals, because measures return 1 value at calc. You see many in a table, but in reality, it is one value. It just recalculates the measure for that row of the table based on the filter context. It isn't returning a column of 4/5 values you can use as a true column.


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.