Such as this example:

MEASURE ‘Internet Sales'[SwitchAmount] =

VAR CurrentMeasure = [SelectedMeasure]

RETURN

SWITCH (

CurrentMeasure,

“This is Workaround Option”, BLANK(),

“Total Margin”, [Internet Total Margin Ugly],

“Total Sales”, [Internet Total Sales Ugly],

“Total Discount Amount”, [Internet Total Discount Amount Ugly],

“Total Freight”, [Internet Total Freight Ugly],

“Total Product Cost”, [Internet Total Product Cost Ugly],

“Total Tax”, [Internet Total Tax Amt Ugly]

)

However it’s not solving in general poor performance of If but just this one particular case.

Roman ]]>

Thanks for proposal. I can confirm it works for this case. So having first option as blank with nonsense condition. Results at similar performance of both queries. Query plan still differs by 1k lines but performance is now comparable. I’ll do another couple of test on my other real life case where impact of option order was vice versa.

Roman

]]>DEFINE

MEASURE ‘Internet Sales'[SwitchAmount] =

VAR CurrentMeasure = [SelectedMeasure]

RETURN

IF (

CurrentMeasure “Total Margin”

&& CurrentMeasure “Total Sales”

&& CurrentMeasure “Total Discount Amount”

&& CurrentMeasure “Total Freight”

&& CurrentMeasure “Total Product Cost”

&& CurrentMeasure “Total Tax”,

BLANK (),

IF (

CurrentMeasure = “Total Margin”,

[Internet Total Margin Ugly],

IF (

CurrentMeasure = “Total Sales”,

[Internet Total Sales Ugly],

IF (

CurrentMeasure = “Total Discount Amount”,

[Internet Total Discount Amount Ugly],

IF (

CurrentMeasure = “Total Freight”,

[Internet Total Freight Ugly],

IF (

CurrentMeasure = “Total Product Cost”,

[Internet Total Product Cost Ugly],

[Internet Total Tax Amt Ugly]

)

)

)

)

)

)

EVALUATE

(

SUMMARIZECOLUMNS (

‘Product Category'[Product Category Name],

‘Product'[Product Subcategory Name],

“Amount”, CALCULATE ( [SwitchAmount], MeasureName[MeasureType] = “Total Margin” )

)

)

ORDER BY

‘Product Category'[Product Category Name],

‘Product'[Product Subcategory Name]

If you do this and switch the measures around will the first real branch also take a performance hit? I’m just curious to know if this is the case. 🙂

Best regards.

]]>unfortunately I do not have any. Whole tested and tuned in SSAS Tabular. ]]>

Great post. Do you have an example PBIX file for this issue?

Thanks! ]]>

thank you ]]>