Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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!!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |