The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Two IF scenario's in one column
Hi,
I am trying to make a column that shows data after two “IF” scenario’s.
Quantity | CreditInvoice | IF Column |
-11346 | False | -11346 |
23547 | True |
|
-2716713.62 | False | -2716713.62 |
-1221689 | False | -1221689 |
-105182 | False | -105182 |
-67 | False | -67 |
6 | True |
|
2752 | True |
|
-2073.08 | False | -2073.08 |
19512 | True |
|
-52189 | True | 52189 |
-78499 | True | 78499 |
I need ‘quantity’ above 0:
Where ‘CreditInvoice’ says TRUE, and the ‘Quantity’ is below 0.
As you can see in the last two rows.
I don’t want anything changing if the ‘CreditInvoice’ is FALSE.
I’ve got that working but that is not the problem,
The second IF scenario is:
When ’CreditInvoice’ is TRUE but the ‘Quantity’ is already above 0.
How do I do this.
I’ve tried the following but is doesn’t work:
IF Column =
IF('Analytical Report'[CreditInvoice] = True,
IF('Analytical Report'[Quantity] < 0, - 'Analytical Report'[Quantity]),
IF('Analytical Report'[CreditInvoice] = True,
IF('Analytical Report'[Quantity] > 0, 'Analytical Report'[Quantity]),
IF('Analytical Report'[CreditInvoice] = False, 'Analytical Report'[Quantity])))
Thanks in advance!
Solved! Go to Solution.
IF Column =
SWITCH (
'Analytical Report'[CreditInvoice]
= TRUE (),
'Analytical Report'[Quantity] < 0, - ( 'Analytical Report'[Quantity] ),
'Analytical Report'[Quantity] > 0, ( 'Analytical Report'[Quantity] ),
'Analytical Report'[Quantity]
)
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!
Sorry @RickPowerBI but I am not exactly following this. I will recommend that you use a SWITCH(TRUE()...) statement versus nested IF statements, much cleaner and easier to follow the logic.
IF Column =
SWITCH (
'Analytical Report'[CreditInvoice]
= TRUE (),
'Analytical Report'[Quantity] < 0, - ( 'Analytical Report'[Quantity] ),
'Analytical Report'[Quantity] > 0, ( 'Analytical Report'[Quantity] ),
'Analytical Report'[Quantity]
)
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!
Thank you very much, using SWITCH is much easier than what I was trying.
User | Count |
---|---|
24 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
29 | |
13 | |
11 | |
10 | |
9 |