Forum Discussion

RvdHeijden's avatar
RvdHeijden
Post Prodigy
9 years ago
Solved

Converting Data type to True/False

I need some help, ive been trying on my own but i cant get it to work.

 

I have a Date table using the CALENDAR function and now i have a formula that converts the dates into workindays with this formula.


Weekday =
IF (
    OR (WEEKDAY ('Date'[Date]) = 1; WEEKDAY ('Date'[Date] ) = 7 );
    FALSE;
    TRUE
)

 

i use this formula in other tables and it works however i cant seem to be able to convert this form 'Tekst' to 'True/False'.
It returns an error stating that it can't convert to a True/False type.

The result is that my formula in another table returns another error because of the error.

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

Doorlooptijd Ticket = VAR DIFF =
    CALCULATE (
        COUNTROWS ( 'Date' );
        ALL ( 'Date' );
        DATESBETWEEN (
            'Date'[Date];
            Tickets[Ticketstart];
            IF ( ISBLANK ( Tickets[Ticketstop]); TODAY (); Tickets[Ticketstop] )
        );
        'Date'[Weekday] = TRUE()
    )
RETURN
    IF ( DIFF = 1; 1; DIFF)

  • MarcelBeug's avatar
    MarcelBeug
    9 years ago

    Strange; after I switched Windows to Nederlands (Nederland) it works with me: take look at this 23 sec video.

    Just like WeekdayMB = MOD(WEEKDAY('Date'[Date]);6)<>1

8 Replies

  • Hi RvdHeijden,

     

    In your formula the format of the results aren't equal try doing this change

    Doorlooptijd Ticket = VAR DIFF =
        CALCULATE (
            COUNTROWS ( 'Date' );
            ALL ( 'Date' );
            DATESBETWEEN (
                'Date'[Date];
                Tickets[Ticketstart];
                IF ( ISBLANK ( Tickets[Ticketstop]); TODAY (); Tickets[Ticketstop] )
            );
            'Date'[Weekday] = TRUE()
        )
    RETURN
        IF ( DIFF = "1"; 1; DIFF)

     

    making the 1 into text should work

     

    Regards,

    MFelix

     

    • RvdHeijden's avatar
      RvdHeijden
      Post Prodigy

      MFelix

      Thanks for your help but the error remains the same.

       

      I think that the error is being triggered by the fact that the 'red' part of the formula refurs to a formula that has the data type of 'Tekst' where it should be 'True/False' but i can't seem to convert that colum.

       

      Your change in the formula had no effect im afraid

      • MFelix's avatar
        MFelix
        Super User

        Try this

         

          IF ( FORMAT(DIFF;"#") = "1"; 1; DIFF)