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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jewb16
New Member

Switch returns wrong totals despite SUMX

Hi Community, 

 

I am new to Power BI. I am trying to build a Balance Sheet from an financial statement which has a few line items recalculated.

I want the code to sum up the Balance sheet using for the positions that are recalculated the corresponding values and for the others the values that were input for the model. 

 

I researched already here and thought, that SUMX would to the job. However, I can't get the totals work correctly. 

 

My Measure is the following (Where [Total Amount] is the input numbers and DIM_Structure[Account] is the line item structure of the Balance Sheet: 

 

Development_Ergebnisübertrag =

var selectedlevel = SELECTEDVALUE(DIM_Structure[Account])
var PnL =
    CALCULATE (
                TOTALYTD([TotalAmount],DIM_Date[FullDateAlternateKey]),
                ALL ( 'DIM_Structure' ),
                'DIM_Structure'[Statement] = "GuV"
    )
 
return
SUMX(VALUES ('DIM_Structure'[Account]),
switch(
        TRUE(),
        selectedlevel = "Ergebnis der Periode", PnL,
        and (selectedlevel = "Gewinnrücklage", MAX(DIM_Date[Monatsname]) = "Dezember"), 10,
        [TotalAmount]
)
)


The result is brings back wrong totals:
 
Jewb16_0-1678952808046.png

 


I thankful for eyery tip how to solve this. 

Best regards
1 REPLY 1
amitchandak
Super User
Super User

@Jewb16 , Try like , assumed you fact name is fact

 

SUMX(summarize(Fact, 'DIM_Structure'[Account],DIM_Date[Monatsname])),
switch(
TRUE(),
selectedlevel = "Ergebnis der Periode", PnL,
and (selectedlevel = "Gewinnrücklage", MAX(DIM_Date[Monatsname]) = "Dezember"), 10,
[TotalAmount]
)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.