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
calerof
Impactful Individual
Impactful Individual

Total measure not working with Summarize

Hello,

I have a measure to calculate a subtraction and the total is not correct. I followed @Greg_Deckler 's Mesaure Totals - The Final Word post. 

This is my single measure code:

Uptime = 
CALCULATE(
    SUMX(
        cr4be_productiondailylog, 
        DIVIDE(
            cr4be_productiondailylog[cr4be_availabletime],
            COUNTA( cr4be_productiondailylog[cr4be_hour] )
        ) - [Downtime Total] )
)

 

This is my Total Measure code:

Uptime Total = 
VAR _table = SUMMARIZE(cr4be_productiondailylog, [cr4be_partnumber],"_value",[Uptime])
RETURN
IF(HASONEVALUE(cr4be_productiondailylog[cr4be_partnumber]), [Uptime], SUMX(_table, [_value]))

 

These are my pbix and data files:

pbix

data

 

This is what I'm getting:

Result.png

 

I appreciate any help.

I'm wondering if I have to change the initial single measure for a simpler one to make it work.

Thanks,

Fernando

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @calerof,

 

You have two main issues on the formula for the total time:

  • Context: When you are making the summarize and add the partnumber you get the calculation for that part number however and since you are using a SUMX the more detail you add if you don't add it to your SUMX  then you will get the calculations only at the top level.
  • Using the Hasonevalue part in the IF statment can also be tricky since if in one of the lines in this case the partnumber has only one value it will pick up the first values on the SUMX that is why he is calculating the 185 and relating to the previous issue the calculations are incorrect.

 

Redo your total to the following measure:

VAR _table =
    SUMMARIZE (
        cr4be_productiondailylog,
        cr4be_productiondailylog[cr4be_workcenter],
        cr4be_productiondailylog[cr4be_mold],
        [cr4be_partnumber],
        cr4be_productiondailylog[cr4be_shiftname],
        "_value", [Uptime]
    )
RETURN
    IF (
        ISINSCOPE ( cr4be_productiondailylog[cr4be_partnumber] ),
        [Uptime],
        SUMX ( _table, [_value] )
    )

 

Check result below and in attach PBIX file.

MFelix_0-1612363820157.png

 


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



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @calerof,

 

You have two main issues on the formula for the total time:

  • Context: When you are making the summarize and add the partnumber you get the calculation for that part number however and since you are using a SUMX the more detail you add if you don't add it to your SUMX  then you will get the calculations only at the top level.
  • Using the Hasonevalue part in the IF statment can also be tricky since if in one of the lines in this case the partnumber has only one value it will pick up the first values on the SUMX that is why he is calculating the 185 and relating to the previous issue the calculations are incorrect.

 

Redo your total to the following measure:

VAR _table =
    SUMMARIZE (
        cr4be_productiondailylog,
        cr4be_productiondailylog[cr4be_workcenter],
        cr4be_productiondailylog[cr4be_mold],
        [cr4be_partnumber],
        cr4be_productiondailylog[cr4be_shiftname],
        "_value", [Uptime]
    )
RETURN
    IF (
        ISINSCOPE ( cr4be_productiondailylog[cr4be_partnumber] ),
        [Uptime],
        SUMX ( _table, [_value] )
    )

 

Check result below and in attach PBIX file.

MFelix_0-1612363820157.png

 


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



calerof
Impactful Individual
Impactful Individual

Hi @MFelix ,

Thank you very much for your analysis, the explanation and help, I appreciate it a lot. That made me understand better the function SUMMARIZE.

Best,

Fernando

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.