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
v-minkum
Microsoft Employee
Microsoft Employee

Getting incorrect value for the below DAX

I use this formula


_TABLE=
VAR suma = SUM([suma])
VAR savi =
SWITCH(
SELECTEDVALUE(Table1[Names]),
"xcds",1,
SUM(Table3[suma])
)

VAR bp = suma-savi
VAR m= DIVIDE(bp,suma)

RETURN
IF(
ISINSCOPE(Table1[Names]) ,
SWITCH(
SELECTEDVALUE( 'Table2'[Names]),
"1", BLANK(),
"2", savi,
"3", BLANK(),
"4", BLANK()
),
IF(
ISINSCOPE('Table2'[Names]),
SWITCH(
SELECTEDVALUE( 'Table2'[Names]),
"1", suma,
"2", savi,
"3", bp,
"4", FORMAT ( m, "percent" )
)
)
)

But sum of savi is wrong in total as it count excepted value "xcds" which i want set to 1, so if xcds = 100 and others 50 , i got total 150 instead of 51, how to fix that?

1 REPLY 1
Angith_Nair
Continued Contributor
Continued Contributor

Hi @v-minkum ,

On the basis of the requirement, you mentioned what I understood is implemented in this measure.

Could you please try this measure..?

_TABLE =
VAR suma =
    SUM ( [suma] )
VAR savi =
    SWITCH (
        SELECTEDVALUE ( Table1[Names] ),
        "xcds", 1,
        SUM ( Table3[suma] )
            - CALCULATE ( SUM ( Table3[suma] ), Table1[Names] = "xcds" ) + 1
    )
VAR bp = suma - savi
VAR m =
    DIVIDE ( bp, suma )
RETURN
    IF (
        ISINSCOPE ( Table1[Names] ),
        SWITCH (
            SELECTEDVALUE ( 'Table2'[Names] ),
            "1", BLANK (),
            "2", savi,
            "3", BLANK (),
            "4", BLANK ()
        ),
        IF (
            ISINSCOPE ( 'Table2'[Names] ),
            SWITCH (
                SELECTEDVALUE ( 'Table2'[Names] ),
                "1", suma,
                "2", savi,
                "3", bp,
                "4", FORMAT ( m, "percent" )
            )
        )
    )

 

 

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.