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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Incorrect total in DAX measure

I have this DAX measure:

Var TablaCalculo = ADDCOLUMNS(
        VALUES('PartesTrabajo'[Empleado_ID]),  -- Reemplaza 'TuCampoDeReferencia' con el campo que identifica las filas en 'PartesTrabajo'
        "Horas", SUM('PartesTrabajo'[Horas]),
        "AsignadoGlobal", [asignado_global]
    )
RETURN

IF(
    SUMX(TablaCalculo, [Horas] - [AsignadoGlobal]) < 0,
    IF(
        MAXX(OrdTrabGeTr,OrdTrabGeTr[Estado]) = "Abierta",
        0,
        SUMX(TablaCalculo, [Horas] - [AsignadoGlobal])
    ),
    SUMX(TablaCalculo, [Horas] - [AsignadoGlobal])
)


The problem is that when we're in the global context, the mesure returns 0 because "Horas" is lower than "AsignadoGlobal" and I want to return the resulted total inside of the IF clause.

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

Try measure like

 

Var TablaCalculo = ADDCOLUMNS(
VALUES('PartesTrabajo'[Empleado_ID]),
"Horas", SUM('PartesTrabajo'[Horas]),
"AsignadoGlobal", [asignado_global],
"Diff", SUM('PartesTrabajo'[Horas]) - [asignado_global]
)
RETURN

SUMX(TablaCalculo,
IF(
MAX(OrdTrabGeTr[Estado]) = "Abierta",
[AsignadoGlobal], // Return the actual negative total
[Diff] // Optionally, handle other cases if needed
)
)

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
Anonymous
Not applicable

MrNimbus_0-1700821432012.png

I think that the "MAX(OrdTrabGeTr[Estado]) = "Abierta" is going to return always only one branch.
I need this condition to check if a Work Order (the record) is still open, and when is the total "case" I just want to forget it and take the result of this logic.

Given this desviation:

MrNimbus_1-1700822270821.png


Is resulting in 0 because of the problem with the measure that I've described earlier.

Expected result: 0 + 14,4 + 7 + 2,5 = 23,9 

 





Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors