Forum Discussion
DAX if else problems
Hi Anonymous
Is there any relationship between your tables 'hourly rate' and 'timeentry'? You should show more info on your model, ideally share the pbix.
In any case, the SUMX is run on the 'hourly rate' table but you are trying to access timeentry[Key]. If this is a column, you have no row context for table timeentry in this expression and thus the code should yield an error. I am surprised it doesn't. I'm guessing the problem with the condition not behaving as you expect will be related to that.
Hi AlB,
So here is my sample:
First table hourly rate:
Key is a calculated column to later match the hourly rate with timeentries.
(1) if "travel time" equals "Ja"; Key is "Fahrtzeit"
(2) if "Task" is not empty; Key is Project + "|" + Task
(3) if "Task" is empty and "Project" is not empty; Key is Project
(4) else Key is Customer
These are like all the posible scenarios. A timeentry could be related to a travel time (1), to a task (2) or to a project (3). If no specific hourly rate is found, the standard customer rate should be matched (4).
This is my timeentries table:
You can ignore column worker. I got my desired results via multiple colums.
"hourly rate" (desired column) is "hourly rate 1" + "hourly rate 2" + "hourly rate 3"
hourly rate DEV is what i would like to have (all the above in one column). I think the problem is, that the nested if clause does not work correctly as the if clauses are subsets of each other.
so its like
IF Condition 1 THEN 1
ELSE IF Condition 2 THEN 2
ELSE IF Condition3 THEN 3
ELSE 4
My understanding is that if one row falls to condition 1 the if clause should stop even if e.g. Condition 3 would also be correct for this row. But in my DAX for "hourly rate DEV" its not working like that.
i hope that helps.
P.S.: The tables are NOT related