DAX SWITCH and AND (multiple IF statements)

serky

New Member
Joined
Jun 30, 2014
Messages
39
Hello all
does anyone know how to add a multiple IF test in one line of a SWITCH statement? I am testing for amounts but sometimes need to check other parameters as well. My example is:

Test:= SWITCH(TRUE(),
values(Table[Amount])=0, "No Sale",
values(Table[Amount])>=100, "Large sales"
AND(values(Table[Amount])=0, values([Table[Seller])="Jane",values(Table[Date])=TODAY()), "No bonus for Jane today!",
"No Data")

In the third line, I need to test amount, the seller and the date but AND only allows 2 arguments so I am getting an error.

How should this be done?

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
In the third line, I need to test amount, the seller and the date but AND only allows 2 arguments so I am getting an error.

You can use the && operator to test more than 2 conditions

=<br><span class="Keyword" style="color:#0070FF">VALUES</span><span class="Parenthesis" style="color:#969696"> (</span> Table[Amount] <span class="Parenthesis" style="color:#969696">)</span> = <span class="Number" style="color:#EE7F18">0</span><br>    && <span class="Keyword" style="color:#0070FF">VALUES</span><span class="Parenthesis" style="color:#969696"> (</span> [Table[Seller] <span class="Parenthesis" style="color:#969696">)</span> = <span class="StringLiteral" style="color:#D93124">"Jane"</span><br>    && <span class="Keyword" style="color:#0070FF">VALUES</span><span class="Parenthesis" style="color:#969696"> (</span> Table[Date] <span class="Parenthesis" style="color:#969696">)</span> = <span class="Keyword" style="color:#0070FF">TODAY</span><span class="Parenthesis" style="color:#969696"> (</span><span class="Parenthesis" style="color:#969696">)</span><br>

or

=<br><span class="Keyword" style="color:#0070FF">AND</span><span class="Parenthesis" style="color:#969696"> (</span><br><span class="indent4">    </span><span class="Keyword" style="color:#0070FF">AND</span><span class="Parenthesis" style="color:#969696"> (</span> <span class="Keyword" style="color:#0070FF">VALUES</span><span class="Parenthesis" style="color:#969696"> (</span> Table[Amount] <span class="Parenthesis" style="color:#969696">)</span> = <span class="Number" style="color:#EE7F18">0</span>, <span class="Keyword" style="color:#0070FF">VALUES</span><span class="Parenthesis" style="color:#969696"> (</span> [Table[Seller] <span class="Parenthesis" style="color:#969696">)</span> = <span class="StringLiteral" style="color:#D93124">"Jane"</span> <span class="Parenthesis" style="color:#969696">)</span>,<br><span class="indent4">    </span><span class="Keyword" style="color:#0070FF">VALUES</span><span class="Parenthesis" style="color:#969696"> (</span> Table[Date] <span class="Parenthesis" style="color:#969696">)</span> = <span class="Keyword" style="color:#0070FF">TODAY</span><span class="Parenthesis" style="color:#969696"> (</span><span class="Parenthesis" style="color:#969696">)</span><br><span class="Parenthesis" style="color:#969696">)</span><br>
 
Upvote 0
Oh my gosh! That is so simple - I am such a twit!

I don't know what's wrong with me but as soon as someone mentions Power Query, DAX, Power Pivot etc, my brain goes to mush (in fact, I wouldn't be surprised if I couldn't spell DAX). For some reason, it seems 1000% harder in these tools than Excel. Hopefully, I'll get over that hump soon ...

I really appreciate you taking time to answer these queries.

Thanks
 
Upvote 0
I don't know what's wrong with me but as soon as someone mentions Power Query, DAX, Power Pivot etc, my brain goes to mush

I think what scares people off is the fact that to use these tools properly you need to learn the theory behind, especially for DAX. Whereas Excel is more about practice, even though some theory is also needed, especially if you want to use VBA
 
Upvote 0

Forum statistics

Threads
1,223,383
Messages
6,171,772
Members
452,423
Latest member
Rene M

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top