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

Dynamic grand total problem depending on switch selection

Hello community,
I'm unsuccessfully trying to show the dynamic Grand Total as the sum of the columns depending on whether or not I select the "Scenario" filter to show more measures.
If I select one measure the total appears

FEST__4-1678475956528.png

but if I select two or more selections it does not appear

FEST__5-1678476068197.png

The reason is that the measures do not talk to each other using the "Scenario" selector which is detached from the model and is used within the measures via the SWITCH function. 
I insert the measure, for simplicity I remove some scenarios
Sum_Scenario_Year = 

//example of recalled measures
//ACT CY = CALCULATE(SUM('CAPEX FOR ENG'[SCENARIO_VALUE]),'CAPEX FOR ENG'[SCENARIO] = "ACT" , DATESYTD(TIME[Date]))
// ACT - 1 = CALCULATE(SUM('CAPEX FOR ENG'[SCENARIO_VALUE]),'CAPEX FOR ENG'[SCENARIO] = "ACT" , DATEADD(DATESYTD(TIME[Date]), -1, YEAR))
// PCL CY = CALCULATE(SUM('CAPEX FOR ENG'[SCENARIO_VALUE]),'CAPEX FOR ENG'[SCENARIO] = "PCL" , DATESYTD(TIME[Date]))

VAR Scenario_value =SWITCH(SELECTEDVALUE('MAIN BASELINE'[MAIN BASELINE]),
                "ACT CY" , [ACT CY],
                "ACT -1",  [ACT -1],
                "PCL CY" , [PCL CY],
             )
RETURN
Scenario_value

I tried to insert a logic for the total but it takes the sum of all the measures without distinction from the selected ones

FEST__6-1678476538035.png

//if (hasonevalue('MAIN BASELINE'[MAIN BASELINE]),Scenario_value ,  [ACT CY]+[ACT -1]+[ACT -2]+[ACT -3]+[FCT CY]+[BDG CY]+[PCL CY]+[EST CY]+[CMT CY]+[FTR + 1]+[FTR + 2]+[FTR + 3]+[FTR + 4]+[FTR + 5])
The model involved is this one

FEST__8-1678477054356.png

I am not sure if this is possible, but any help regarding this issue is greatly appreciated! Thank you in advance!
FEST

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Sum_Scenario_Year =
SUMX (
VALUES ( 'MAIN BASELINE'[MAIN BASELINE] ),
SWITCH (
'MAIN BASELINE'[MAIN BASELINE],
"ACT CY", [ACT CY],
"ACT -1", [ACT -1],
"PCL CY", [PCL CY]
)
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Sum_Scenario_Year =
SUMX (
VALUES ( 'MAIN BASELINE'[MAIN BASELINE] ),
SWITCH (
'MAIN BASELINE'[MAIN BASELINE],
"ACT CY", [ACT CY],
"ACT -1", [ACT -1],
"PCL CY", [PCL CY]
)
)

Anonymous
Not applicable

Hi @tamerj1 , 

It works!!! 🙂

Thank you very much for both resolution suggestions
FEST__0-1678543174796.png

FEST

Anonymous
Not applicable

HI @amitchandak , 

I tried as you indicated but I still don't see the total when I have two scenarios 😞

FEST__1-1678539449460.png

 

FEST

amitchandak
Super User
Super User

@Anonymous , Change return like

Sumx( values('MAIN BASELINE'[MAIN BASELINE]), Scenario_value)

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.

Top Solution Authors