# DAX SWITCH and AND (multiple IF statements)



## serky (Aug 21, 2018)

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


----------



## VBA Geek (Aug 22, 2018)

> 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>


----------



## serky (Aug 22, 2018)

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


----------



## VBA Geek (Aug 22, 2018)

> 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


----------

