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
ArchStanton
Post Prodigy
Post Prodigy

DAX IF Statement producing errors highlighted in red font

Hi,

I have this written this DAX code but its producing the red error bar as per screenshot and I'm not sure why?

Also, could this be better written using Variables possibly?

ArchStanton_1-1660560170493.png

 

 

Into Area Date = if('Cases - Active'[Functional Area] = "Assessment", 'Cases - Active'[tpo_legacycasecreationdate],if('Cases - Active'[Functional Area] = "Casework Support", 'Cases - Active'[new_allocationqueuecaseworksupport], if('Cases - Active'[Functional Area] = "Adjudication", 'Cases - Active'[tpo_datepassedtoadjudication], if('Cases - Active'[Functional Area] = "Early Resolution", 'Cases - Active'[tpo_dateofertacceptance], if('Cases - Active'[Functional Area] = "Assessment" && 'Cases - Active'[Sub Area] = "Assessment Post ERT", 'Cases - Active'[tpo_datepassedfromearlyresolution],0)))))

 

Thanks,

1 ACCEPTED SOLUTION

@ArchStanton 
Yes sir, if you have got the correct results already then don't worry about it.

View solution in original post

9 REPLIES 9
ArchStanton
Post Prodigy
Post Prodigy

Thanks, writing it like this is definitely easier to understand or possibly debug in future.

The DAX still produces errors though:

 

ArchStanton_0-1660561028783.png

 

@ArchStanton 
What does the error say? Are you sure you are creating a calculated column not a measure?

I'm still learning PowerBI so please bare with me. 

I can't see an error message but In the right hand corner this RED box appears when I go to the end of the code on line 14:

ArchStanton_0-1660561749580.png

(and the FunctionalArea names are all in Red Font - does that not sugeest a problem)?

 

This is a new column that will contain only dates that I will use on my visuals.

 

Hope that makes sense?

@ArchStanton 
Two possibilities I can think of. Either you are creating a measure by mistake or you are creating the column in the another table. In order to see the error you need to hit "Enter" and see the error message at the botom of formula box.

Thanks,

I've hit Enter at the bottom of the Formula Box and nothing happens? Everything is Grey all the way to line 14 but despite this the column has been populated by dates - so could I assume that everything is working and just ignore the red?

 

Also, the TRUE values such as Assessment, Casework Support etc are the same named values that exist in another table called 'Stage and Area', I'm not sure how that could affect this calculated column as we are in a different table?

 

Lastly, as this column contains dates that depend on the logical test being TRUE or FALSE, the column was created in the Cases - Active table to compute this. There is no measure icon for this column anywhere.

If you are suggesting this is a measure then should I be seeing this as Meaure in the field bar instead of a Date icon?

Unless I explicitly click on New Measure I cannot see how a measure be created by accident?

 

Thanks for being patient!

@ArchStanton 
Have you tried to restart the power bi desktop application?

Yes and the red bar is still there.

Like I said previously, the dates have been populated in that column, although there are about a 1,000 empty cells. Maybe I should just ignore it

@ArchStanton 
Yes sir, if you have got the correct results already then don't worry about it.

tamerj1
Super User
Super User

Hi @ArchStanton 
Please try

Into Area Date =
VAR FunctionalArea = 'Cases - Active'[Functional Area]
VAR SubArea = 'Cases - Active'[Sub Area]
RETURN
    SWITCH (
        TRUE,
        FunctionalArea = "Assessment", 'Cases - Active'[tpo_legacycasecreationdate],
        FunctionalArea = "Casework Support", 'Cases - Active'[new_allocationqueuecaseworksupport],
        FunctionalArea = "Adjudication", 'Cases - Active'[tpo_datepassedtoadjudication],
        FunctionalArea = "Early Resolution", 'Cases - Active'[tpo_dateofertacceptance],
        FunctionalArea = "Assessment"
            && SubArea = "Assessment Post ERT", 'Cases - Active'[tpo_datepassedfromearlyresolution],
        0
    )

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.