March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi all,
My problem: I'm not able to add a third value (= [Value3] to evaluate in my SWITCH-statement. It automatically jumps to [Result3].
Explanation:
I'm using a two SWITCH-statements.
The first one is to determine if an employee has:
1) a salesfactor (e.g. hourly wage of € 10,00 * salesfactor 220% = €22,00), or;
2) a fixed sales price (e.g. €25,00)
If an employee has a salesfactor then SWITCH#2 will be activated, where I want to add three conditions:
1) Weekday (Mo-Fr) & No holiday;
2) Saturday & No holiday;
3) Sunday & No holiday;
The problem is that I'm not able to add the 3th condition (= Sunday & No holiday).
My SWITCH-statement automatically jumps to [Result3] and doesn't let me fill in a [Value3] to evaluate.
As you can see in picture 2, adding a comma after [Result2] doesn't show [Value3], but [Result3].
I've tried everything, but it doesn't give me a solution. Anyone can help me?
Solved! Go to Solution.
@krampit1 To improve readability I would recommend this approach and I have noted where conditions and values should go:
SalesAmount =
VAR VerkooptariefNormaal =
RELATED ( Personeel[Uurloon] ) * RELATED ( Personeel[Verkoopfactor] )
VAR VerkooptariefZaterdag =
VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_zaterdag] )
VAR VerkooptariefZondag =
VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_zondag] )
VAR __Value1 =
IF (
'Eigen overzichten'[UrenOVW1] > 0,
'Eigen overzichten'[UrenOVW1] * ( VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_ovw1] ) ),
0
)
VAR __Value2 =
IF (
'Eigen overzichten'[UrenOVW2] > 0,
'Eigen overzichten'[UrenOVW2] * ( VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_ovw2] ) ),
0
)
RETURN
SWITCH (
TRUE (),
RELATED ( Personeel[Verkoopfactor] ) > 0,
SWITCH (
TRUE (),
'Eigen overzichten'[WeekofWeekend] = "Weekdag"
&& 'Eigen overzichten'[Feestdag] = "Geen feestdag",
'Eigen overzichten'[UrenNormaal] * VerkooptariefNormaal + __Value1 + __Value2,
'Eigen overzichten'[Weekdag] = "Zaterdag"
&& 'Eigen overzichten'[Feestdag] = "Geen feestdag",
'Eigen overzichten'[UrenNormaal] * VerkooptariefZaterdag + __Value1 + __Value2, //if this is the last condition, remove ,
//next condition goes here with ,
//next value goes here
), //ends 2nd SWITCH
RELATED ( Personeel[Verkoopprijs_vast] ) > 0, 'Eigen overzichten'[UrenNormaal] * RELATED ( Personeel[Verkoopprijs_vast] )
) //Ends first SWITCH
Thank you for your reply @Greg_Deckler. I've added the code as text and used Daxformatter.com. Thank you for that recommendation. The issue still remains. I've added a comma at the end (=red circle), but the statement still shows [Result3] first and no [Value3] at all.
@krampit1 Please paste your code as text and please use the daxformatter.com to properly format your code. I can see a ton of improvements that will improve readability of your code. Consider that it may just be the case of the intellisense getting confused and not really an issue.
@krampit1 To improve readability I would recommend this approach and I have noted where conditions and values should go:
SalesAmount =
VAR VerkooptariefNormaal =
RELATED ( Personeel[Uurloon] ) * RELATED ( Personeel[Verkoopfactor] )
VAR VerkooptariefZaterdag =
VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_zaterdag] )
VAR VerkooptariefZondag =
VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_zondag] )
VAR __Value1 =
IF (
'Eigen overzichten'[UrenOVW1] > 0,
'Eigen overzichten'[UrenOVW1] * ( VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_ovw1] ) ),
0
)
VAR __Value2 =
IF (
'Eigen overzichten'[UrenOVW2] > 0,
'Eigen overzichten'[UrenOVW2] * ( VerkooptariefNormaal * RELATED ( Opdrachtgever[Tarief_ovw2] ) ),
0
)
RETURN
SWITCH (
TRUE (),
RELATED ( Personeel[Verkoopfactor] ) > 0,
SWITCH (
TRUE (),
'Eigen overzichten'[WeekofWeekend] = "Weekdag"
&& 'Eigen overzichten'[Feestdag] = "Geen feestdag",
'Eigen overzichten'[UrenNormaal] * VerkooptariefNormaal + __Value1 + __Value2,
'Eigen overzichten'[Weekdag] = "Zaterdag"
&& 'Eigen overzichten'[Feestdag] = "Geen feestdag",
'Eigen overzichten'[UrenNormaal] * VerkooptariefZaterdag + __Value1 + __Value2, //if this is the last condition, remove ,
//next condition goes here with ,
//next value goes here
), //ends 2nd SWITCH
RELATED ( Personeel[Verkoopprijs_vast] ) > 0, 'Eigen overzichten'[UrenNormaal] * RELATED ( Personeel[Verkoopprijs_vast] )
) //Ends first SWITCH
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
114 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
164 | |
116 | |
63 | |
57 | |
50 |