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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
thisguyjc
Regular Visitor

DAX Measure not showing a Total Value in the "Total Row"

Hello!

I've tried looking around and I just can't find why it's not showing the Total Value in the "Total Row"


Code:

Lön =
VAR NormalTimmar = SELECTEDVALUE(Dim_Lon[NormalarbetstidMånad])
VAR FastLon = SELECTEDVALUE(Dim_Lon[Fast Lön])
VAR Overtid = SELECTEDVALUE(Dim_Lon[Övertidsersättning/h])
VAR Timlon = SELECTEDVALUE(Dim_Lon[TimlönAlla])
VAR Semesterersattning = SELECTEDVALUE(Dim_Lon[Semestererättningtimanställda(%)]) / 100
VAR Anstallningstyp = SELECTEDVALUE(Dim_Lon[Anställningstyp])

RETURN
    SUMX(
        VALUES(Dim_Date[Date]),
        VAR ArbetadeTimmar = CALCULATE(SUM(Fact_Tidsrapport[Timmar]), Dim_Date[Date] = EARLIER(Dim_Date[Date]))
        RETURN
            SWITCH(
                TRUE(),
                AND(Anstallningstyp = "Heltid", ArbetadeTimmar > NormalTimmar),
                    FastLon + ((ArbetadeTimmar - NormalTimmar) * Overtid),
                AND(Anstallningstyp = "Heltid", ArbetadeTimmar = NormalTimmar),
                    FastLon,
                AND(Anstallningstyp = "Deltid", ArbetadeTimmar > NormalTimmar),
                    FastLon + ((ArbetadeTimmar - NormalTimmar) * Overtid),
                AND(Anstallningstyp = "Deltid", ArbetadeTimmar = NormalTimmar),
                    FastLon,
                Anstallningstyp = "Timanställd",
                    (Timlon * ArbetadeTimmar) + (Timlon * ArbetadeTimmar * Semesterersattning),
                Timlon * ArbetadeTimmar
            )
    )
6 REPLIES 6
v-jiewu-msft
Community Support
Community Support

Hi @thisguyjc ,

Based on the description, try using ISINSCOPE function.

Lön =
VAR NormalTimmar = SELECTEDVALUE(Dim_Lon[NormalarbetstidMånad])
VAR FastLon = SELECTEDVALUE(Dim_Lon[Fast Lön])
VAR Overtid = SELECTEDVALUE(Dim_Lon[Övertidsersättning/h])
VAR Timlon = SELECTEDVALUE(Dim_Lon[TimlönAlla])
VAR Semesterersattning = SELECTEDVALUE(Dim_Lon[Semestererättningtimanställda(%)]) / 100
VAR Anstallningstyp = SELECTEDVALUE(Dim_Lon[Anställningstyp])

RETURN
IF(
    ISINSCOPE(Dim_Lon[Anställningstyp]),
    SUMX(
        VALUES(Dim_Date[Date]),
        VAR ArbetadeTimmar = CALCULATE(SUM(Fact_Tidsrapport[Timmar]), Dim_Date[Date] = EARLIER(Dim_Date[Date]))
        RETURN
            SWITCH(
                TRUE(),
                AND(Anstallningstyp = "Heltid", ArbetadeTimmar > NormalTimmar),
                    FastLon + ((ArbetadeTimmar - NormalTimmar) * Overtid),
                AND(Anstallningstyp = "Heltid", ArbetadeTimmar = NormalTimmar),
                    FastLon,
                AND(Anstallningstyp = "Deltid", ArbetadeTimmar > NormalTimmar),
                    FastLon + ((ArbetadeTimmar - NormalTimmar) * Overtid),
                AND(Anstallningstyp = "Deltid", ArbetadeTimmar = NormalTimmar),
                    FastLon,
                Anstallningstyp = "Timanställd",
                    (Timlon * ArbetadeTimmar) + (Timlon * ArbetadeTimmar * Semesterersattning),
                Timlon * ArbetadeTimmar
            )
    )
)

ISINSCOPE function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-jiewu-msft !

Unfortunately all the Data just turned blank in the table with the inscope function.

Greg_Deckler
Super User
Super User

@thisguyjc First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
suparnababu8
Super User
Super User

Hi @thisguyjc 

 

Try with this measure 

Lön =
VAR NormalTimmar = MAX(Dim_Lon[NormalarbetstidMånad])
VAR FastLon = MAX(Dim_Lon[Fast Lön])
VAR Overtid = MAX(Dim_Lon[Övertidsersättning/h])
VAR Timlon = MAX(Dim_Lon[TimlönAlla])
VAR Semesterersattning = MAX(Dim_Lon[Semestererättningtimanställda(%)]) / 100
VAR Anstallningstyp = MAX(Dim_Lon[Anställningstyp])

RETURN
    SUMX(VALUES(Dim_Date[Date]),
        VAR ArbetadeTimmar = CALCULATE(SUM(Fact_Tidsrapport[Timmar]), Dim_Date[Date] = EARLIER(Dim_Date[Date]))
        RETURN
            SWITCH(TRUE(),
                AND(Anstallningstyp = "Heltid", ArbetadeTimmar > NormalTimmar),
                    FastLon + ((ArbetadeTimmar - NormalTimmar) * Overtid),
                AND(Anstallningstyp = "Heltid", ArbetadeTimmar = NormalTimmar),
                    FastLon,
                AND(Anstallningstyp = "Deltid", ArbetadeTimmar > NormalTimmar),
                    FastLon + ((ArbetadeTimmar - NormalTimmar) * Overtid),
                AND(Anstallningstyp = "Deltid", ArbetadeTimmar = NormalTimmar),
                    FastLon,
                Anstallningstyp = "Timanställd",
                    (Timlon * ArbetadeTimmar) + (Timlon * ArbetadeTimmar * Semesterersattning),
                Timlon * ArbetadeTimmar)
    )

 

Let me know if it works

Ummh wait actually, I counted the total and it should be around 6,389,299 but it became "11,817,750"

So it kinda almost doubled on the total 😮

Hello @suparnababu8!

Thank you very much, this helped!

What was your thought process regarding this? How did you know to changed SELECTEDVALUE into MAX?

I'm pretty new to PowerBI and DAX so it's hard for me to understand some stuff.

Helpful resources

Announcements
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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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