Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi people... I'm having a problem with a DAX formula.
I'm trying to get the absolute difference between two columns ( "HH ASIGNADAS" and "HH EJECUTADAS")
Now, in those cases in which there is no value in the "HH ASIGNADAS" column, said difference should not be made. To achieve this I'm using the following expression (measure):
Solved! Go to Solution.
I'd try this and tweak as necessary:
DIF =
SUMX (
VALUES ( ENTREGABLES[CODIGO ENTREGABLE] ),
VAR _Asignadas = CALCULATE ( SUM ( BBDD1[HH ASIGNADAS] ) )
VAR _Ejutadas = CALCULATE ( SUM ( HH_ejecutadas_minedoc[Horas_ejecutadas] ) )
RETURN
IF (
ISBLANK ( _Asignadas ), /*|| ISBLANK ( _Ejutatas ),*/
BLANK (),
ABS ( _Asignadas - _Ejutadas )
)
)
I've included a commented-out part that you can include if you want to check both are nonblank.
I'd try this and tweak as necessary:
DIF =
SUMX (
VALUES ( ENTREGABLES[CODIGO ENTREGABLE] ),
VAR _Asignadas = CALCULATE ( SUM ( BBDD1[HH ASIGNADAS] ) )
VAR _Ejutadas = CALCULATE ( SUM ( HH_ejecutadas_minedoc[Horas_ejecutadas] ) )
RETURN
IF (
ISBLANK ( _Asignadas ), /*|| ISBLANK ( _Ejutatas ),*/
BLANK (),
ABS ( _Asignadas - _Ejutadas )
)
)
I've included a commented-out part that you can include if you want to check both are nonblank.
Can I ask you a question? Why did you use Calculate in this expression and not just SUM?
Context transition. I want the SUM to be calculated within the context of the current ENTREGABLES[CODIGO ENTREGABLE] row of SUMX.
Further reading:
https://www.sqlbi.com/articles/understanding-context-transition/
https://www.sqlbi.com/articles/understanding-context-transition-in-dax/
It worked!! Thank you very much!!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 16 | |
| 8 | |
| 7 | |
| 7 |