The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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 |
---|---|
26 | |
10 | |
8 | |
5 | |
5 |
User | Count |
---|---|
33 | |
13 | |
11 | |
9 | |
8 |