Forum Discussion

thewookie's avatar
thewookie
Helper I
5 months ago
Solved

Help with Pareto chart

Hello:   I am decent with Power BI, DAX and M, but I have been messing with a problem for a while. I have used Google and Copilot looking for help without success. I has asked to create two pareto ...
  • MFelix's avatar
    MFelix
    5 months ago

    Hi thewookie ,

     

    Believe I have found the question and is related with context of your calculations:

    • Total Losses current syntax:
    Total Losses=
    CALCULATE (
        [Production Loss (MT)],
        FILTER (
            ALLSELECTED ( 'Partial Data Set' ),
            'Partial Data Set'[PERK] <> "Low Sales Demand"
                && 'Partial Data Set'[PERK] <> "Planned Maintenance"
                && 'Partial Data Set'[PERK] <> "Plant Turnaround (Strategic Outage)"
                && 'Partial Data Set'[PERK] <> "Weekend"
                && [Production Loss (MT)] > 0
        )
    )
    • The ALLSELECTED returns all rows in a table, or all the values in a columns, ignoring any filters that might have been applied inside the query, but keeping filters that come from outside. This means that when you apply the filter for the 80% that filter context is taken into consideration so your overall calculation is not on top of the full data but on the specific data you filter out

     

    Then you have the question about the running loss:

    • This calculation is done picking up the Running Loss measure and the getting the total losses, however when you filter the calculations based on the percentage the results get changed because the Running loss is nonw getting not only a filter at perk level but also at line level because it's part of the context

     

    If you change the measure to the following you should get the proper result:

    Total Losses Adjusted=
    CALCULATE (
        [Production Loss (MT)],
        FILTER (
            ALL ( 'Partial Data Set' ),
            'Partial Data Set'[PERK] <> "Low Sales Demand"
                && 'Partial Data Set'[PERK] <> "Planned Maintenance"
                && 'Partial Data Set'[PERK] <> "Plant Turnaround (Strategic Outage)"
                && 'Partial Data Set'[PERK] <> "Weekend"
                && [Production Loss (MT)] > 0
        )
    )
    
    
    Running Loss % Adjusted = 
     DIVIDE(
        CALCULATE([Running Loss Measure], REMOVEFILTERS('Partial Data Set'[Line])),
        [Total Losses Adjusted]
     )


    Has you can see the left side (filter adjusted measures) now maches the left side (no filter original measures).

     

    Be aware that this may need some more tweeks based on your model. 

     

    See PBIX file attached.