Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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!!
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |