Forum Discussion

Jack2of3's avatar
Jack2of3
Icon for Helper II rankHelper II
4 years ago
Solved

IF ('A'[B] = BLANK(), 'A'[C], 'A'[D]) Cannot convert data type text to true/false

Going in circles. I need a column that does 3 evaluations on different fields and provides different results based on the different fields. Gives error cannot convert data type TEXT to TRUE/FALSE

 

REASSIGN =
IF(DetailCkReq[Batch_Str] = "REC", "RECURRING") ||
 
IF(DetailCkReq[CKREQ_ASSIGNMENT.CKREQ_NO.] = BLANK(),
DetailCkReq[NAME], DetailCkReq[CKREQ_ASSIGNMENT.ASSIGNED_TO]) ||
 
IF(DetailCkReq[BATCH_ASSIGNMENT.BATCH_NAME] = BLANK(),
DetailCkReq[NAME], DetailCkReq[BATCH_ASSIGNMENT.ASSIGNED_TO])
  • Your DAX is trying to evaluate a logical combination of strings like "RECURRING" || "Detail Name" || "Detail Name", which doesn't make any sense since || can only combine True/False values, not text strings.

     

    I think you may want something more like this:

    REASSIGN =
    SWITCH (
        TRUE (),
        DetailCkReq[Batch_Str] = "REC", "RECURRING",
        ISBLANK ( DetailCkReq[CKREQ_ASSIGNMENT.CKREQ_NO.] ),  DetailCkReq[NAME],
        ISBLANK ( DetailCkReq[BATCH_ASSIGNMENT.BATCH_NAME] ), DetailCkReq[NAME],
        DetailCkReq[BATCH_ASSIGNMENT.ASSIGNED_TO]
    )

4 Replies

  • SWITCH(TRUE(),DetailCkReq[Batch_Str] = "REC", "RECURRING",
    SWITCH (TRUE(),DetailCkReq[CKREQ_ASSIGNMENT.CKREQ_NO.] = BLANK(),
    DetailCkReq[NAME], DetailCkReq[CKREQ_ASSIGNMENT.ASSIGNED_TO]),
     SWITCH(TRUE(),DetailCkReq[BATCH_ASSIGNMENT.BATCH_NAME] = BLANK(),
    DetailCkReq[NAME], DetailCkReq[BATCH_ASSIGNMENT.ASSIGNED_TO]))
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Jack2of3 
    The results of your IF statements are Text Strings or false:
    1 - is either "Recurring" or false
    2 - is either [NAME] or [CKREQ_ASSIGNMENT.ASSIGNED_TO]
    3 - [NAME] or [CKREQ_ASSIGNMENT.ASSIGNED_TO]

    You have then included 1 or 2 or 3 which is expecting True/False , True/False or True/False.

    I think you need to change the nesting of the conditions into a singe if statement.  However, I would consider moving this logic back into the Power Query.

    I hope this helps point you in the right direction.

     

  • Your DAX is trying to evaluate a logical combination of strings like "RECURRING" || "Detail Name" || "Detail Name", which doesn't make any sense since || can only combine True/False values, not text strings.

     

    I think you may want something more like this:

    REASSIGN =
    SWITCH (
        TRUE (),
        DetailCkReq[Batch_Str] = "REC", "RECURRING",
        ISBLANK ( DetailCkReq[CKREQ_ASSIGNMENT.CKREQ_NO.] ),  DetailCkReq[NAME],
        ISBLANK ( DetailCkReq[BATCH_ASSIGNMENT.BATCH_NAME] ), DetailCkReq[NAME],
        DetailCkReq[BATCH_ASSIGNMENT.ASSIGNED_TO]
    )
    • Jack2of3's avatar
      Jack2of3
      Icon for Helper II rankHelper II

      Perfect! I knew it had to be possible I just couldn't wrap my head around it.