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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Metricbits
Frequent Visitor

Measure with switch - incorrect totals

Hi,

 

I have the following measure:

 

 

 

BS Act GC =
SWITCH (
    VALUE ( CALCULATE ( MIN ( BalanceSheet[FxTypeNumber] ), ALL ( 'Calendar' ) ) ),
    1, [BS Act GC MnthEnd],
    2, [BS Act GC Historical]
)

 

 

 

where two other measures used in the one above are:

 

 

BS Act GC MnthEnd =
DIVIDE ( [BS Act LC], [BS Rate EOM] )

 

 

 

and

 

 

 

BS Act GC Historical =
CALCULATE (
    SUMX (
        BalanceSheet,
        DIVIDE (
            [BS Act LC],
            IF (
                ISBLANK (
                    LOOKUPVALUE (
                        'Exchange Rates'[Amount],
                        'Exchange Rates'[Month], BalanceSheet[Date],
                        'Exchange Rates'[Currency], BalanceSheet[BaseCurrency],
                        'Exchange Rates'[FX_Type], BalanceSheet[FxType]
                    )
                ),
                1,
                LOOKUPVALUE (
                    'Exchange Rates'[Amount],
                    'Exchange Rates'[Month], BalanceSheet[Date],
                    'Exchange Rates'[Currency], BalanceSheet[BaseCurrency],
                    'Exchange Rates'[FX_Type], BalanceSheet[FxType]
                )
            )
        )
    ),
    FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
)

 

 

 

However, the total for the top measure (BS Act GC) doesn't add up correctly

Metricbits_0-1611904500877.png

 

I normally use summarize to fix similar issues but I can't figure out how to apply it correctly with SWITCH. Please help

1 ACCEPTED SOLUTION
Metricbits
Frequent Visitor

I solved the problem using this measure instead:

 

BS Act GC = 
VAR BalanceSheetVirt =
    ADDCOLUMNS (
        CALCULATETABLE (
            BalanceSheet,
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
        ),
        "Rate Month End",
            LOOKUPVALUE (
                'Exchange Rates'[Amount],
                'Exchange Rates'[Currency], BalanceSheet[BaseCurrency],
                'Exchange Rates'[Month], MAX ( 'Calendar'[MonthStartDate] ),
                'Exchange Rates'[FX_Type], "Month End"
            ),
        "Rate Historical",
            LOOKUPVALUE (
                'Exchange Rates'[Amount],
                'Exchange Rates'[Currency], BalanceSheet[BaseCurrency],
                'Exchange Rates'[Month], BalanceSheet[Date],
                'Exchange Rates'[FX_Type], "Month End"
            )
    )
RETURN
    SUMX (
        BalanceSheetVirt,
        IF (
            VALUE ( BalanceSheet[FxTypeNumber] ) = 1,
            [Amount_LC] / [Rate Month End],
            [Amount_LC] / [Rate Historical]
        )
    )

View solution in original post

2 REPLIES 2
Metricbits
Frequent Visitor

I solved the problem using this measure instead:

 

BS Act GC = 
VAR BalanceSheetVirt =
    ADDCOLUMNS (
        CALCULATETABLE (
            BalanceSheet,
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
        ),
        "Rate Month End",
            LOOKUPVALUE (
                'Exchange Rates'[Amount],
                'Exchange Rates'[Currency], BalanceSheet[BaseCurrency],
                'Exchange Rates'[Month], MAX ( 'Calendar'[MonthStartDate] ),
                'Exchange Rates'[FX_Type], "Month End"
            ),
        "Rate Historical",
            LOOKUPVALUE (
                'Exchange Rates'[Amount],
                'Exchange Rates'[Currency], BalanceSheet[BaseCurrency],
                'Exchange Rates'[Month], BalanceSheet[Date],
                'Exchange Rates'[FX_Type], "Month End"
            )
    )
RETURN
    SUMX (
        BalanceSheetVirt,
        IF (
            VALUE ( BalanceSheet[FxTypeNumber] ) = 1,
            [Amount_LC] / [Rate Month End],
            [Amount_LC] / [Rate Historical]
        )
    )
MFelix
Super User
Super User

Hi @Metricbits ,

 

Have you tried doing the a SUMX of the Class based on isinscope?

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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