Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I'm fairly new to Dax and I'm curious why one piece of code works the way I'd expect, but the other does not.
I have a measure:
TM Num X:= Calculate(Distinctcount([UserID]), Filter(factTable, [TM Denom] = 1 && not(isblank([ShipDate]))), (DATESBETWEEN(DimDate[Date],[FYSTARTDATE],[FYENDDATE])) ,USERELATIONSHIP(DimDate[Date],factTable[ShipDate])
Which doesn't work, however, when I do this, I get the desired result, I just have to use 2 measures.
TM Num X:= Calculate(Distinctcount([UserID]), Filter(factTable, [TM Denom] = 1 && not(isblank([ShipDate]))),(DATESBETWEEN(DimDate[Date],[FYSTARTDATE],[FYENDDATE]))) TMX2:= [TM Num X] (USERELATIONSHIP(DimDate[Date],factTable[ShipDate]))
Can someone please explain why the first one doesn't work?
Solved! Go to Solution.
I don't really understand the formulas in the Original post. The second formula isnt invalid. I assume it is supposed to be a calculate. The second post doesn't even contain the userelationships part, so I don't see how it can give the same result.
The filter portion of calculate operates in the current filter context.
Regarding the first formula in the first post.
the use relationships portion is applied at the same time as the filter portion. Use relationships is applied with filter, not TO filter
Regarding the second set of formulas in the first post
Your second formula applies the inactive relationship first, then executes the first formula. As a result, the first formula operates in a filter context with the new relationship applied already
Rewriting it like this gives the desired result, I'm thinking it may have to do with filter/row context but I still am unsure why i get bad numbers in the original statement.
Edited:
TM Num X:= Calculate(Distinctcount([UserID]), [TM Denom] = 1 , not(isblank([ShipDate]))), USERELATIONSHIP(DimDate[Date],FactTable[ShipDate]),((DATESBETWEEN(DimDate[Date],[FYSTARTDATE],[FYENDDATE]))
I don't really understand the formulas in the Original post. The second formula isnt invalid. I assume it is supposed to be a calculate. The second post doesn't even contain the userelationships part, so I don't see how it can give the same result.
The filter portion of calculate operates in the current filter context.
Regarding the first formula in the first post.
the use relationships portion is applied at the same time as the filter portion. Use relationships is applied with filter, not TO filter
Regarding the second set of formulas in the first post
Your second formula applies the inactive relationship first, then executes the first formula. As a result, the first formula operates in a filter context with the new relationship applied already
Sorry, I was retyping it from memory on my mobile and I forgot to include that, so of course it didn't make sense. Thanks for your reply. I've only been using DAX for about a week.
Can you please explain "
Regarding the first formula in the first post.
the use relationships portion is applied at the same time as the filter portion. Use relationships is applied with filter, not TO filter " a bit more?
Thanks! I'll mark it as the answer.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
64 |
User | Count |
---|---|
135 | |
122 | |
101 | |
71 | |
61 |