Forum Discussion
Optimize this DAX
Hello,
Is there a way to optimize this DAX for a calculated column?
I call Lookup 3 times.
Thank You,
Michael
try the following :
cc =
var v1 = LOOKUPVALUE ( Input[Description], Input[Cost Center], Input[Level 2] )
var v2 = LOOKUPVALUE ( Input[Description], Input[Cost Center], Input[Level 1] )
var v3 = LOOKUPVALUE ( Input[Description], Input[Cost Center], Input[Level 2] )
return
switch(
true() ,
isblank(v1) , v2 , v3 )
let me know if this helps.If my answer helped sort things out for you, i would appreciate a thumbs up π and mark it as the solution β
It makes a difference and might help someone else too. Thanks for spreading the good vibes! π€ :
2 Replies
- Daniel29195Community Champion
try the following :
cc =
var v1 = LOOKUPVALUE ( Input[Description], Input[Cost Center], Input[Level 2] )
var v2 = LOOKUPVALUE ( Input[Description], Input[Cost Center], Input[Level 1] )
var v3 = LOOKUPVALUE ( Input[Description], Input[Cost Center], Input[Level 2] )
return
switch(
true() ,
isblank(v1) , v2 , v3 )
let me know if this helps.If my answer helped sort things out for you, i would appreciate a thumbs up π and mark it as the solution β
It makes a difference and might help someone else too. Thanks for spreading the good vibes! π€ : - AnonymousNot applicable
Hi mikebi
You can optimize your DAX by reducing the number of times is called. This can be achieved by using a variable to store the result of the first call and then reusing that variable in your statement.
Please try changing dax to:
Level 2 Description = VAR Result = LOOKUPVALUE(Input[Description], Input[Cost Center], Input[Level 2]) RETURN IF( ISBLANK(Result), LOOKUPVALUE(Input[Description], Input[Cost Center], Input[Level 1]), Result )This approach can help improve performance by reducing the number of calls to the calculated column from three to a maximum of two.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.