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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
RvdHeijden
Post Prodigy
Post Prodigy

Need help correcting my Formula

Hello,

 

Ive got a formula that needs some work, there are a lot of IF's in

 

Status Schouw = IF(OR(Adressen[R.N.A.]="R40";(Adressen[R.N.A.]="R42"));"";
    IF(Adressen[Civiel geplande datum]=BLANK();"Civiel nog niet gepland";
        IF(Adressen[schouwen begin]=BLANK();"Schouw nog niet gepland";
            IF(OR(Adressen[schouwen gesloten]=BLANK();(Adressen[schouwen begin]<>BLANK()));"Bulkplanning";
                IF(OR(Adressen[schouwen gesloten]=BLANK();(Adressen[Schouw datum]<NOW()));"Te laat";
                    IF(Adressen[schouwen gesloten]<>BLANK();"Gesloten";
                        IF(MID(Adressen[schouwen begin];14;18)<>"00:00";"Vaste afspraak";
                            IF(SUMX(adressen;Adressen[Civiel geplande datum]-NOW())<21;"Te Laat";""))))))))

 

DAX comparison operations do not support comparing values of type Text with values of type Date. Consider using the VALUE or FORMAT function to convert one of the values.

 

I believe the error is caused in the last line because he needs to calculate the number of days between 2 colums and if its less then 21 days it should return the value 'Te laat'

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@RvdHeijden,

There is no issue with the last line when I make a test using sample data in my table. Could you please check that if you change the data type of Schouw datum field to Date? If this field is a text field, the above error will occur because you are comparing text values with date values in the following part. Also ensure that you have defined the data type of the Civiel geplande datum field to Date.

Adressen[Schouw datum]<NOW()

If the above step doesn't help, please share sample data of your table for us to test.

Regards,
Lydia

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

hi @RvdHeijden,

 

Your formula seems fine but you could display it a in a neater way using Daxformatter.com

 

Status Schouw =
IF (
    OR ( Adressen[R.N.A.] = "R40"; ( Adressen[R.N.A.] = "R42" ) );
    "";
    IF (
        Adressen[Civiel geplande datum] = BLANK ();
        "Civiel nog niet gepland";
        IF (
            Adressen[schouwen begin] = BLANK ();
            "Schouw nog niet gepland";
            IF (
                OR (
                    Adressen[schouwen gesloten] = BLANK ();
                    ( Adressen[schouwen begin] <> BLANK () )
                );
                "Bulkplanning";
                IF (
                    OR (
                        Adressen[schouwen gesloten] = BLANK ();
                        ( Adressen[Schouw datum] < NOW () )
                    );
                    "Te laat";
                    IF (
                        Adressen[schouwen gesloten] <> BLANK ();
                        "Gesloten";
                        IF (
                            MID ( Adressen[schouwen begin]; 14; 18 ) <> "00:00";
                            "Vaste afspraak";
                            IF (
                                SUMX ( adressen; Adressen[Civiel geplande datum] - NOW () )
                                    < 21;
                                "Te Laat";
                                ""
                            )
                        )
                    )
                )
            )
        )
    )
)




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian@Anonymous

Ive changed a few date colums because 2  were indeed referring to a tekst value.

They looked like dates but they were the outcome of a formula and the data type was set to 'tekst'.

 

So problem solved....thanks 🙂

Anonymous
Not applicable

@RvdHeijden,

There is no issue with the last line when I make a test using sample data in my table. Could you please check that if you change the data type of Schouw datum field to Date? If this field is a text field, the above error will occur because you are comparing text values with date values in the following part. Also ensure that you have defined the data type of the Civiel geplande datum field to Date.

Adressen[Schouw datum]<NOW()

If the above step doesn't help, please share sample data of your table for us to test.

Regards,
Lydia

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors