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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

if DAX formula error

Hi Experts

 

Cannot see the error in my if formula.

_Status = IF(ScheduleTask[status]="Complete", "Complete",IF(ScheduleTask[status]="Cancelled","Cancel",IF(and (ScheduleTask[status]="Active",ScheduleTask[primaryAuthor]=""),"Unassigned",IF(and (ScheduleTask[status]="Active",ScheduleTask[primaryAuthor]<>""),"Assigned",IF(and (ScheduleTask[status]="Active",ScheduleTask[LifecycleStatusMatch]=""),"inProgress",ScheduleTask[LifecycleStatusMatch])))))
6 REPLIES 6
az38
Community Champion
Community Champion

Hi @Anonymous 

highky recommend to use SWITCH() as mentioned @mahoneypat 

 

_Status = 
SWITCH(TRUE(),
ScheduleTask[status]="Complete", "Complete",
ScheduleTask[status]="Cancelled","Cancel",
ScheduleTask[status]="Active" && ScheduleTask[primaryAuthor]="", "Unassigned",
ScheduleTask[status]="Active" && ScheduleTask[primaryAuthor]<>"", "Assigned",
ScheduleTask[status]="Active" && ScheduleTask[LifecycleStatusMatch]="", "inProgress",
ScheduleTask[LifecycleStatusMatch]
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
amitchandak
Super User
Super User

@Anonymous, I think you should like

_Status = IF(ScheduleTask[status]="Complete", "Complete",IF(ScheduleTask[status]="Cancelled","Cancel",
IF( (ScheduleTask[status]="Active",ScheduleTask[primaryAuthor]=""),"Unassigned",
IF( (ScheduleTask[status]="Active",ScheduleTask[primaryAuthor]<>""),"Assigned",
IF( ScheduleTask[status]="Active",ScheduleTask[LifecycleStatusMatch]=""),"inProgress",ScheduleTask[LifecycleStatusMatch]))))

 

I doubt use of AND

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Amit

 

its giving me errors with out the and....

mahoneypat
Microsoft Employee
Microsoft Employee

Did you consider writing this as a SWITCH(TRUE(),... expression instead of nested IF()s? Check out this post. 

https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/

Not sure if you want to rewrite this one but it will make the next one easier. 

Regards

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

hi Pat

 

not sure that is going to work its a calculated column in a table, my faut forgot to mention that.

Switch(true() works in calculated columns too.  Here is what it your expression would look like with that approach:

 

_Status = SWITCH(TRUE(),
ScheduleTask[status]="Complete", "Complete",
ScheduleTask[status]="Cancelled","Cancel",
AND(ScheduleTask[status]="Active",ScheduleTask[primaryAuthor]=""),"Unassigned",
AND(ScheduleTask[status]="Active",ScheduleTask[primaryAuthor]<>""),"Assigned",
AND(ScheduleTask[status]="Active",ScheduleTask[LifecycleStatusMatch]=""),"inProgress",
ScheduleTask[LifecycleStatusMatch])
 
Easier to read at least.  Does that work?
 
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors