Forum Discussion
SWITCH and IF always doing eager evaluation
trattnh - I'm not sure if this a query or if you are providing information. But yes SWITCH and IF will likely use the same query plan if the Vertipaq engine evaluation decides EAGER is the best option. You can force IF to do an EAGER evalution with IF. EAGER
Incidentally, you probably dont need the LOOKUPVALUE in your selected_measure_name variable. If there is one "measure" per "field_name" you can just use MAX( my_table[measure_name] ) because however you are selecting field_name the MAX will always grab the appropriate measure_name from the row of this table. This version should be slightly quicker in DAX Studio.
You can find more information here: https://www.sqlbi.com/articles/understanding-eager-vs-strict-evaluation-in-dax/
- trattnh2 years agoFrequent Visitor
This is a query. My issue is that assuming that measures 1, 2, 3 all take the same time to execute, the SWITCH or IFstatement should take the same time to execute regardless of how many options I have in them. In reality, the time increases for every option I add. If I add options for measures 4, 5, 6 the statement will take twice the amount of time than if I only had measures 1, 2, 3, even though only a single measure should be evaluated according to the value of selected_measure_name.
In effect, I am trying to write a measure that "gets as input" another measure by name and then returns the value of that measure - this is in order to prevent the need to duplicate complex measures where the only difference is the name of an internal measure it is calling