Forum Discussion

MaleneL's avatar
MaleneL
Icon for Resolver I rankResolver I
3 years ago
Solved

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

Hi all

I am working on at DAX formular to get the stage for the last day last year, but I get the above message.

the formular is 

Stadie EOY =

VAR _StadieEOY =
    CALCULATE(
        FIRSTNONBLANK(Fact_DWH[Stage_Name],1),
            FILTER(
                Fact_DWH,
                Fact_DWH[FBK_Date#Int#EndOfMonth] = 'Fact_DWH'[FBK_Date#Int#EndOfYear]
                    && Fact_DWH[Customer] = 'Fact_DWH'[Customer]))
Return
if(ISBLANK(_StadieEOY),0,_StadieEOY)
How can i work around that the stage Name is not at numer?

CustomerFBK_Date#Int#EndOfMonthFBK_Date#Int#EndOfYearStage_Namestage EOY LY
128-02-202331-12-20221b??
228-02-202331-12-20222c??
328-02-202331-12-20223d??
428-02-202331-12-20222c??
528-02-202331-12-20221b??
131-12-202231-12-20213d??
231-12-202231-12-20212c??
331-12-202231-12-20211b??
431-12-202231-12-20211b??
531-12-202231-12-20212c??

 

hope you can help

Malene

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi MaleneL 

    The type of value you want to return is Text type, but the number type returned by 0 in the if statement you defined, the two returned value types are different, so an error will be reported, you can refer to the following new expression

    Stadie EOY = 
     var  _StadieEOY=CALCULATE(
            FIRSTNONBLANK(Fact_DWH[Stage_Name],1),
                FILTER(
                    Fact_DWH,
                    Fact_DWH[FBK_Date#Int#EndOfMonth] = EARLIER('Fact_DWH'[FBK_Date#Int#EndOfYear])
                        && Fact_DWH[Customer] = EARLIER('Fact_DWH'[Customer])))
    return IF(ISBLANK(_StadieEOY),"None",_StadieEOY)

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi MaleneL 

    The type of value you want to return is Text type, but the number type returned by 0 in the if statement you defined, the two returned value types are different, so an error will be reported, you can refer to the following new expression

    Stadie EOY = 
     var  _StadieEOY=CALCULATE(
            FIRSTNONBLANK(Fact_DWH[Stage_Name],1),
                FILTER(
                    Fact_DWH,
                    Fact_DWH[FBK_Date#Int#EndOfMonth] = EARLIER('Fact_DWH'[FBK_Date#Int#EndOfYear])
                        && Fact_DWH[Customer] = EARLIER('Fact_DWH'[Customer])))
    return IF(ISBLANK(_StadieEOY),"None",_StadieEOY)

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.