Forum Discussion
Blablabla
2 years agoAdvocate I
Translate SQL query with complex CASE to DAX
Hello, I have this query where FactPXD is 1 to many to Dept and the filter direction is single from the Dept to FactPXD, how can I create this measure in DAX : SELECT
SUM(
CASE
...
- 2 years ago
Try the following :
Your measure = CALCULATE ( SUMX ( FactPXD, SWITCH ( TRUE(), RELATED(Dept[DeptName]) IN {"A", "T"}, FactPXD[QTY], RELATED(Dept[DeptTpe]) = "B" && FactPXD[QTY] < 0, FactPXD[QTY], 0 ) ), FILTER ( Dept, LEFT(Dept[Dept Group], 1) = "T" && LEFT(Dept[Dept Group], 2) <> "TC" ) )
AmiraBedh
2 years agoSuper User
Try the following :
Your measure =
CALCULATE (
SUMX (
FactPXD,
SWITCH (
TRUE(),
RELATED(Dept[DeptName]) IN {"A", "T"}, FactPXD[QTY],
RELATED(Dept[DeptTpe]) = "B" && FactPXD[QTY] < 0, FactPXD[QTY],
0
)
),
FILTER (
Dept,
LEFT(Dept[Dept Group], 1) = "T" &&
LEFT(Dept[Dept Group], 2) <> "TC"
)
)