Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Expressions that yield variant data-type cannot be used to define calculated columns.

i get an error while having the below caluclated column
IF('Scores'[Current/Last]="-","-",IF('Scores'[Question Scores]<>0, IF(_score='Scores'[Question Scores],0,_score) ))
 
Do anyone know how to solve the error? 

5 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous Try below. You either need to return all text or all numbers, not text and numbers.

    IF('Scores'[Current/Last]="-","-",IF('Scores'[Question Scores]<>0, IF(_score='Scores'[Question Scores],"0",_score & "") ))

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      But if i return it into calculated column, it will return error as well. Or i need to use the format function in DAX? if yes, how should it be like?

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Anonymous The measure I posted returns all text. Alternatively, you could write the formula this way to return either BLANK or numbers and it would work as well:

        IF('Scores'[Current/Last]="-",BLANK(),IF('Scores'[Question Scores]<>0, IF(_score='Scores'[Question Scores],0,_score) ))