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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
lauramirlyn1
Regular Visitor

Pareto measure do work correctly when adding a slicer by year

I am using the below  measure to create a pareto chart. If I dont select the years in the slicer it seems to be working correctly.

 

1.png

However when I select a year is not working correctly,

2.png

 

Measure:

Pareto % =
VAR _total = CALCULATE(
    [Total Cost]
    , ALLSELECTED('in'[Function L5])
)
VAR _current = [Total Cost]
VAR _sumTable = SUMMARIZE(
    ALLSELECTED('in')
    , 'in'[Function L5]
    , "Cost", [Total Cost]
)
VAR _cummulativeSum = SUMX(
    FILTER(_sumTable, [Total Cost]>= _current)
    ,[Total Cost]
)
RETURN
DIVIDE(_cummulativeSum, _total)
 
Can someone help me figure out what Im missing here!
Thanks,
Laura
 
 
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from DataNinja777 , please allow me to provide another insight: 
Hi  @lauramirlyn1 ,

I created some data:

vyangliumsft_0-1724034719447.png

 

Here are the steps you can follow:

1. Create measure.

Pareto % =
VAR _total = CALCULATE(
    [Total Cost]
    , ALLSELECTED('in'[Function L5])
)
VAR _sumTable = SUMMARIZE(
    ALLSELECTED('in')
    , 'in'[Function L5]
    , "Cost", [Total Cost]
)
VAR _sumTable2 =
ADDCOLUMNS(
    _sumTable,"Sum_Cummulativesum",SUMX(FILTER(_sumTable,[Cost]>=EARLIER([Cost])),[Total Cost]))
var _cummulativeSum=
SUMX(
    FILTER(_sumTable2,[Function L5]=MAX('in'[Function L5])),[Sum_Cummulativesum])
RETURN
DIVIDE(
   _cummulativeSum,_total)

2. Result:

vyangliumsft_1-1724034719452.png

If the results above don't meet your expectations, Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

4 REPLIES 4
Anonymous
Not applicable

Thanks for the reply from DataNinja777 , please allow me to provide another insight: 
Hi  @lauramirlyn1 ,

I created some data:

vyangliumsft_0-1724034719447.png

 

Here are the steps you can follow:

1. Create measure.

Pareto % =
VAR _total = CALCULATE(
    [Total Cost]
    , ALLSELECTED('in'[Function L5])
)
VAR _sumTable = SUMMARIZE(
    ALLSELECTED('in')
    , 'in'[Function L5]
    , "Cost", [Total Cost]
)
VAR _sumTable2 =
ADDCOLUMNS(
    _sumTable,"Sum_Cummulativesum",SUMX(FILTER(_sumTable,[Cost]>=EARLIER([Cost])),[Total Cost]))
var _cummulativeSum=
SUMX(
    FILTER(_sumTable2,[Function L5]=MAX('in'[Function L5])),[Sum_Cummulativesum])
RETURN
DIVIDE(
   _cummulativeSum,_total)

2. Result:

vyangliumsft_1-1724034719452.png

If the results above don't meet your expectations, Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

DataNinja777
Super User
Super User

Hi @lauramirlyn1 ,

 

Please try the following dax formula which respect any slicers applied to the data, including year slicers. This ensures that the calculations are only done within the context of the selected year(s) or any other slicers.

 

Pareto % =
VAR _total = CALCULATE(
    SUM('in'[Total Cost]),
    ALLSELECTED('in')
)
VAR _current = [Total Cost]
VAR _sumTable = 
    SUMMARIZE(
        ALLSELECTED('in'),
        'in'[Function L5],
        "Cost", SUM('in'[Total Cost])
    )
VAR _cumulativeSum = 
    SUMX(
        FILTER(_sumTable, [Cost] >= _current),
        [Cost]
    )
RETURN
DIVIDE(_cumulativeSum, _total)

Best regards,

Hi @DataNinja777 ,

I tried it and still doing the same.

lauramirlyn1_0-1723815563667.png

 

Hi @lauramirlyn1 ,

 

I tried with the dummy data and it is producing your required output in both before and after Pareto% measures.  

DataNinja777_1-1723821012419.png

DataNinja777_2-1723821030681.png

DataNinja777_3-1723821070182.png

 

 

DataNinja777_0-1723820986919.png

I have attached an example pbix file.  

Best regards,

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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