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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Fahad5
Frequent Visitor

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

Hi all,

 

Please help below function is getting error,

 

Please help me.

 

Partition-1 = IF(ISBLANK(TOKENFLEX_COUNT[Partition_1]),FORMAT(TODAY()-1,"yyyymmdd"),TOKENFLEX_COUNT[Partition_1])
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You'll get this error if the result-if-true and the result-if-false arguments of IF return different data types, for example, text when true and a number when false.

 

If you want to return text in the case of a blank, then you need to also return text when it's not blank too. You could use FORMAT there as well. For example,

Partition-1 =
VAR Partition = TOKENFLEX_COUNT[Partition_1]
RETURN
    IF (
        ISBLANK ( Partition ),
        FORMAT ( TODAY () - 1, "yyyymmdd" ),
        FORMAT ( Partition, "Standard" )
    )

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Fahad5,

Did these suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
AlexisOlson
Super User
Super User

You'll get this error if the result-if-true and the result-if-false arguments of IF return different data types, for example, text when true and a number when false.

 

If you want to return text in the case of a blank, then you need to also return text when it's not blank too. You could use FORMAT there as well. For example,

Partition-1 =
VAR Partition = TOKENFLEX_COUNT[Partition_1]
RETURN
    IF (
        ISBLANK ( Partition ),
        FORMAT ( TODAY () - 1, "yyyymmdd" ),
        FORMAT ( Partition, "Standard" )
    )
VahidDM
Super User
Super User

Hi @Fahad5 

 

Try this:

Partition-1 =
IF(
    ISBLANK( [Partition_1] ),
    FORMAT( TODAY() - 1, "yyyymmdd" ),
    [Partition_1]
)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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