Forum Discussion
MichaelSamiotis
Resolver I
3 years agoData modelling with Dim dates[Year] doesn't work
Hello all. I have the below DAX (1) which doesn't work (returns nothing) and I don't get why. When I change it to the second DAX code (2) it works fine. I have a 1-* relationship between Dim Date...
- 3 years ago
Is the relationship Active? Your code should work as written so something else is going on. Could try this code to test out the variables....
Customers = VAR theYear = YEAR ( TODAY() ) VAR currentDateYear = MAX(Dim Dates'[Year]) VAR calculation = CALCULATE ( DISTINCTCOUNT ( 'Fact Sales'[customer_id] ), 'Dim Dates'[Year] = theYear ) // RETURN calculation // Uncomment to see the executed value // RETURN theYear // Uncomment to see the executed value // RETURN currentDateYear // Uncomment to see the executed value
KeyurPatel14
Responsive Resident
3 years agoHi MichaelSamiotis ,
Can you please provide your pbix file?
Because I think it should work as you expected.
- MichaelSamiotis3 years ago
Resolver I
Sorry can't due to data protection issues but I really don't get why it doesn't work. It should. Data formats are both integers (whole numbers), I have a 1 to * relationship on the date filed.
- BrianConnelly3 years ago
Resolver III
Is the relationship Active? Your code should work as written so something else is going on. Could try this code to test out the variables....
Customers = VAR theYear = YEAR ( TODAY() ) VAR currentDateYear = MAX(Dim Dates'[Year]) VAR calculation = CALCULATE ( DISTINCTCOUNT ( 'Fact Sales'[customer_id] ), 'Dim Dates'[Year] = theYear ) // RETURN calculation // Uncomment to see the executed value // RETURN theYear // Uncomment to see the executed value // RETURN currentDateYear // Uncomment to see the executed value