Forum Discussion
Jeanxyz
5 years agoPower Participant
switch() syntax
Hi, I'm reading a DAX measure created by another developer and I get stuck with the following measure.
Reporting Amount Base_PL = SWITCH(
[Selected Currency],1,
[Group Currency Amount Base_PL (EUR)],2,
[Company Currency Amount Base_PL],3,
[Budget Currency Amount Base_PL (EUR)])
Can someone explain to me where is the evaluation condition in the function? I did a few test, it looks the formula always generate specific amounts instead of 1, 2,3,4. So why the function uses 1,2,3,4?
Reporting Amount Base_PL = SWITCH ( [Selected Currency], 1, [Group Currency Amount Base_PL (EUR)], 2, [Company Currency Amount Base_PL], 3, [Budget Currency Amount Base_PL (EUR)] )Jeanxyz based on your question this is where the condition is getting checked:
Reporting Amount Base_PL = SWITCH ( [Selected Currency], --take the value of selected currency 1, [Group Currency Amount Base_PL (EUR)], --if it is 1 return this measure 2, [Company Currency Amount Base_PL], --if it is 2 return this measure 3, [Budget Currency Amount Base_PL (EUR)] -- if it is 3 return this measure ) --if none of above condition met, means selected currency is not 1, 2, 3 it will return blank
3 Replies
- CNENFRNLCommunity Champion
Reporting Amount Base_PL = SWITCH ( [Selected Currency], 1, [Group Currency Amount Base_PL (EUR)], 2, [Company Currency Amount Base_PL], 3, [Budget Currency Amount Base_PL (EUR)] ) - parry2kSuper User
Jeanxyz based on your question this is where the condition is getting checked:
Reporting Amount Base_PL = SWITCH ( [Selected Currency], --take the value of selected currency 1, [Group Currency Amount Base_PL (EUR)], --if it is 1 return this measure 2, [Company Currency Amount Base_PL], --if it is 2 return this measure 3, [Budget Currency Amount Base_PL (EUR)] -- if it is 3 return this measure ) --if none of above condition met, means selected currency is not 1, 2, 3 it will return blank- JeanxyzPower Participant
Thank you so much! I see what you mean 🙂 I will use dax formatter next time.