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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
DiDiliz
Regular Visitor

Add multiple selectedvalues

I am trying to create a measure which will add up the separate values which are selected in the slicer.  However, because each value has a different calculation, I don't want it to add up the whole selection, I want it to add A to B to C etc.  

 

I have a graph showing hours per month, I also have a another graph showing the same data but totalled for the months selected.  The hours I need are calculated using an average figure for each month, but if I select all months it averages the figures from all months rather than using the average for May + the average for June etc. 

 

I tried using 

Test Measure 2 = CALCULATE(IF(SELECTEDVALUE('TABLE1'[Week Commencing ].[Month]) = "May", SUM('TABLE2'[Hours]) * AVERAGE('TABLE1'[Budget %]),0.0)) + CALCULATE(IF(SELECTEDVALUE('TABLE1'[Week Commencing ].[Month]) = "June", SUM('TABLE2'[Hours]) * AVERAGE('TABLE1'[Budget %]),0.0))

 

however this only returns a value when I select one month at a time, it does not add the sum of May to the sum of June. 

 

Is there a way to add selected values to each other rather than lumping them together into a total sum. 

 

Thanks

1 ACCEPTED SOLUTION
Angith_Nair
Continued Contributor
Continued Contributor

Hi @DiDiliz 

Use the below dax:

Test Measure =
SUMX(
    VALUES('TABLE1'[Week Commencing].[Month])
    CALCULATE(
        SUM('TABLE2'[Hours]) * AVERAGE('TABLE1'[Budget %]),
        FILTER(
            'TABLE1',
            'TABLE1'[Week Commencing].[Month] = EARLIER('TABLE1'[Week Commencing].[Month])
        )
    )
)

View solution in original post

5 REPLIES 5
DiDiliz
Regular Visitor

I have now realised that I am having the same problem when filtering people with the slicers.  Rather than adding person 1 + person 2 + person 3, it's averaging the budget % over all 3 people to give the result.  Is there a way to add a second filter to the above measure to separate out people as well.  The data for people is in the same table as the months above.  

anmolmalviya05
Solution Sage
Solution Sage

Hi @DiDiliz , Please try the below measure

Test Measure 2 =
SUMX(
VALUES('TABLE1'[Week Commencing].[Month]), -- Iterate over selected months
SWITCH(
TRUE(),
'TABLE1'[Week Commencing].[Month] = "May", SUM('TABLE2'[Hours]) * AVERAGE('TABLE1'[Budget %]),
'TABLE1'[Week Commencing].[Month] = "June", SUM('TABLE2'[Hours]) * AVERAGE('TABLE1'[Budget %]),
0 -- Default value for other months or no selection
)
)

It's letting me select more than one month, however it's doubling the total.  So May should be 74 but it's showing 149, June should be 67 but together with May it's showing 284. 

 

This does feel like progress though.  Thank you 

Angith_Nair
Continued Contributor
Continued Contributor

Hi @DiDiliz 

Use the below dax:

Test Measure =
SUMX(
    VALUES('TABLE1'[Week Commencing].[Month])
    CALCULATE(
        SUM('TABLE2'[Hours]) * AVERAGE('TABLE1'[Budget %]),
        FILTER(
            'TABLE1',
            'TABLE1'[Week Commencing].[Month] = EARLIER('TABLE1'[Week Commencing].[Month])
        )
    )
)

That's done exactly what I was after.  Thank you so much. 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.