Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rocky09
Solution Sage
Solution Sage

Stuck with Multiple If Conditions

can any one help me on this situation.

 

I have below table. I need to get "OnTime" and "OverDue" Status based on the following criteria. 

 

PART NO.SERVICEExceptionLASTDATEDays Status
UY4352JAQNo29-05-2017 09:014 
UZ0014RetNo26-05-2017 09:5320 
UZ0UY7RetNo26-05-2017 09:5320 
UZ0201RetNo26-05-2017 08:5220 
UZ0281RetNo26-05-2017 13:0320 
UZ224RetNo27-05-2017 03:3821 
UZ282RetNo27-05-2017 17:2821 
UZ418RetNo27-05-2017 20:5921 
AC0024JAQNo29-05-2017 00:378 
AW0075JAQNo29-05-2017 06:288 
AW0081JAQNo29-05-2017 06:268 
AW0090JAQNo29-05-2017 06:248 
BC0218JAQNo29-05-2017 03:258 
BJ0554JAQNo29-05-2017 04:127 
ND0105FlyNo28-05-2017 22:0420 
ND0106FlyNo28-05-2017 21:5020 
ND0107FlyNo28-05-2017 21:5020 
OP0245FlyNo28-05-2017 20:3020 
OP0254FlyNo28-05-2017 07:1720 
OP0354FlyYes28-05-2017 20:3020 
OP0380FlyNo28-05-2017 22:1920 
CF0622RetNo27-05-2017 23:1621 
CG0006JAQNo28-05-2017 12:534 
CG0341JAQNo28-05-2017 20:418 
CN0092JAQNo29-05-2017 09:148 
CN0UZ1JAQNo29-05-2017 02:447 
CN0UZ2JAQNo29-05-2017 02:447 
CN0137JAQNo26-05-2017 17:438 
CN0138JAQNo26-05-2017 17:438 
CN0147JAQyes29-05-2017 02:194 
CN0148JAQNo29-05-2017 02:194 
CN0156JAQNo28-05-2017 20:238 
DB0635FlyNo29-05-2017 02:418 
DB0652FlyNo27-05-2017 00:5121 
DB0690JAQYes29-05-2017 03:207 
DB0691FlyNo27-05-2017 00:5121 
DB0693JAQNo29-05-2017 03:207 
DC0009FlyYes29-05-2017 09:418 
DD0235JAQNo29-05-2017 02:218 
DD0240JAQNo29-05-2017 02:218 
DD0490FlyNo29-05-2017 03:488 
DG0371FlyNo29-05-2017 10:388 
DG0649FlyNo29-05-2017 11:158 
DG0799JAQNo29-05-2017 11:174 
PO0149RetNo27-05-2017 00:2621 
PO0236RetNo27-05-2017 23:4621 
JH0291JAQNo29-05-2017 04:477 
JH0322JAQNo29-05-2017 04:487 
JH0652JAQNo23-05-2017 07:567 
JH0653JAQNo23-05-2017 07:567 
LJ0240FlyNo29-05-2017 08:198 
LB0795FlyNo29-05-2017 09:568 

 

 

Criteria :

 

if [LastDate] is blank then [Status] = "OverDue"

if [Service] = "JAQ" and [Exception] = "Yes" and [Days]  < 8 then "OnTime(E)"

if [Service] = "JAQ" and [Exception] = "Yes" and [Days]  > 8 then "OverDue(E)"

if [Service] = "JAQ" and [Exception] = "NO"and [Days]  < 15 then "OnTime" and  [Days]  > 15 then "OverDue"

if [Service] <> "JAQ" and [Days]  < 20 then "OnTime" and  [Days]  > 20 then "OverDue"

 

any help is much appreciated. 🙂

Thank you in advance,

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

This should do the trick, however you need to reconsider your logic for whenever [Days] = your criteria.  All of your statements deal with Above and Below, but never on the same day.  For the below i've had to assume what you wanted.

 

Status = IF(
	ISBLANK([LastDate]),
	"OverDue",
	IF(
		[Service] = "JAQ",
		IF(
			[Exception] = "Yes",
			IF(
				[Days] < 8,
				"OnTime(E)",
				"OverDue(E)"
			),
			IF(
				[Days] < 15,
				"OnTime",
				"OverDue"
			)
		),
		IF(
			[Days] < 20,
			"OnTime",
			"OverDue"
		)
	)
)	

View solution in original post

Phil_Seamark
Employee
Employee

Could you try something like....

 

 

Status = SWITCH (TRUE() ,
[LastDate] = blank() , "OverDue" [Service] = "JAQ" && [Exception] = "Yes" && [Days] < 8 , "OnTime(E)" [Service] = "JAQ" && [Exception] = "Yes" && [Days] > 8 , "OverDue(E)" [Service] = "JAQ" && [Exception] = "NO" && [Days] < 15 , "OnTime"
[Service] = "JAQ" && [Exception] = "NO" && [Days] > 15 , "OverDue" [Service] <> "JAQ" && [Days] < 20 , "OnTime"
[Service] <> "JAQ" && [Days] > 20 , "OverDue"
-----ELSE------
"Other")

 

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Employee
Employee

Could you try something like....

 

 

Status = SWITCH (TRUE() ,
[LastDate] = blank() , "OverDue" [Service] = "JAQ" && [Exception] = "Yes" && [Days] < 8 , "OnTime(E)" [Service] = "JAQ" && [Exception] = "Yes" && [Days] > 8 , "OverDue(E)" [Service] = "JAQ" && [Exception] = "NO" && [Days] < 15 , "OnTime"
[Service] = "JAQ" && [Exception] = "NO" && [Days] > 15 , "OverDue" [Service] <> "JAQ" && [Days] < 20 , "OnTime"
[Service] <> "JAQ" && [Days] > 20 , "OverDue"
-----ELSE------
"Other")

 

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

This should do the trick, however you need to reconsider your logic for whenever [Days] = your criteria.  All of your statements deal with Above and Below, but never on the same day.  For the below i've had to assume what you wanted.

 

Status = IF(
	ISBLANK([LastDate]),
	"OverDue",
	IF(
		[Service] = "JAQ",
		IF(
			[Exception] = "Yes",
			IF(
				[Days] < 8,
				"OnTime(E)",
				"OverDue(E)"
			),
			IF(
				[Days] < 15,
				"OnTime",
				"OverDue"
			)
		),
		IF(
			[Days] < 20,
			"OnTime",
			"OverDue"
		)
	)
)	

thank you so much @Anonymous @Phil_Seamark

 

Both are working fine.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.