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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DouweMeer
Post Prodigy
Post Prodigy

Expressions that yield variant data type cannot be used

I created a logic to combine a product description from multiple excel files. At one point it started giving me a data variant error so I was looking for numbers in my expression. I was unable to find the number so I tried something 'silly'. The result was unexpected:

 

Untitled.png

Trying to improve, I tried the following, which 'worked' as in that the error was gone. 

 

Curious that this one is accepted in a text columnCurious that this one is accepted in a text column

This is acceptedThis is accepted

 

When placing the "1" on any of the other position, the error returns and sticks. But when you double on one of the VAR's, the issue is gone. 

 

Untitled4.png

 

Removing the single "1" and replacing it by a blank() does not return the error. Also, replacing the "1" by just 1, does solve the problem as well. 

 

Untitled5.png

 

I have no clue how to solve it. 

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @DouweMeer ,

Based on your description, perhaps you can try to put the a6 variable in the last swtich() statement to get the result:

Column =
VAR a1 =
    BLANK ()
VAR a2 =
    BLANK ()
VAR a3 =
    BLANK ()
VAR a4 =
    BLANK ()
VAR a5 =
    BLANK ()
VAR a6 = "1"
RETURN
    SWITCH (
        TRUE (),
        a5 <> BLANK (), a5,
        a2 <> BLANK (), a2,
        a4 <> BLANK (), a4,
        a1 <> BLANK (), a1,
        a3 <> BLANK (), a3,
        a6 <> BLANK (), a6,
        BLANK ()
    )

re.png

 

Best Regards,
Yingjie Li

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

@v-yingjl 

Strange that this removes the behavior. Although extremely unfavourable as this expression is meant to swtich between product tabels dependable on priority. In some fields some of the sources do not have a related data field and therefore a blank is entered in the VAR. If I would change the position for each field to make sure that the last VAR is always filled in, it becomes a mess to write, maintain, and check on it. 

I'll report a ticket to make sure they fix this. It shouldn't be like this. 

amitchandak
Super User
Super User

@DouweMeer , With data type text and blank(), it should not give this. Try to move a6 as first and try.

 

I tried this and it worked

Measure = VAR A1 = blank() 
VAR A2= blank() 
VAR A3 = blank() 
VAR A4 = 4
return switch(True() , 
A1<> BLANK(),A1 ,
A2<> BLANK(),A2 ,
A3<> BLANK(),A3 ,
A4<> BLANK(),A4 
)

@amitchandak 

I assume you meant it like below. If so, that doesn't work either.

 

Untitled.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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