Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello everyone,
I'm trying to get working a measure where I apply a filter based on the difference between 2 measures :
The final measure looks like this, and it works indeed:
CALCULATE(DISTINCTCOUNT('fact Prescripciones'[Id Prescripcion]),filter(ALLSELECTED('fact Prescripciones'[Id Prescripcion]),DATEDIFF([ultima_fecha_mes],[Last_available_date],DAY)>2)
But trying to reduce the ammount of measures on my model, I wanted to include the other 2 measures using just VAR:
Solved! Go to Solution.
Hi @okusai3000
Variables in DAX are immutable once they are assigned a value at declaration. In your example,
VAR Last_available_date is evaluated before the FILTER(ALLSELECTED(.... )) and the value obtained stored.
When used within the FILTER(...) Last_available_date will always provide that same result in each iteration. The measure, on the contrary, is calculated anew for each row as the FILTER( ...), with context transition doing its crucial work.
You need either the measure or the full code
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Hi @okusai3000
Variables in DAX are immutable once they are assigned a value at declaration. In your example,
VAR Last_available_date is evaluated before the FILTER(ALLSELECTED(.... )) and the value obtained stored.
When used within the FILTER(...) Last_available_date will always provide that same result in each iteration. The measure, on the contrary, is calculated anew for each row as the FILTER( ...), with context transition doing its crucial work.
You need either the measure or the full code
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
69 | |
61 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |