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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
juhoneyighot
Helper III
Helper III

Problem with DAX IFERROR formula

I'doing this IFERROR DAX formula:

Phase _ = IFERROR(IF('stx__legacy_fsjob'[# of _]="","", FIND("~", SUBSTITUTE('stx__legacy_fsjob'[_JobType_txt],"_","~",'stx__legacy_fsjob'[# of _]-1))),'stx__legacy_fsjob'[_JobType_txt])

However, this error occurs: Expressions that yield variant data-type cannot be used to define calculated columns.

Does PowerBI has IFerror formula? I only saw IF and IF.EAGER. 

Thank you for the help.

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @juhoneyighot,

I think this should be more related to your data source connection mode. AFAIK, direct query mode has limited the Dax functions usage.
For this sceniaro, you can't create calculate columns in direct query with complex Dax functions. I'd like to suggest you use measure expression instead.

Regards,

Xiaoxin Sheng

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

View solution in original post

10 REPLIES 10
v-shex-msft
Community Support
Community Support

HI @juhoneyighot,

I think this should be more related to your data source connection mode. AFAIK, direct query mode has limited the Dax functions usage.
For this sceniaro, you can't create calculate columns in direct query with complex Dax functions. I'd like to suggest you use measure expression instead.

Regards,

Xiaoxin Sheng

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

@juhoneyighot 

Maybe try IF ( ISERROR (.....

@tamerj1 

I think we can use convert formula to convert those string blank value to text  just as the same in below dAX FORMULA. but my problem is I am new to powerbi dax formula writing so I had a hard time doin this.

# of _ =
IF('stx__legacy_fsjob'[NC.IN]="","",CONVERT((LEN('stx__legacy_fsjob'[_JobType_txt])-(LEN(SUBSTITUTE('stx__legacy_fsjob'[_JobType_txt],"_","")))),STRING))
Note:The issue was your expression have true part as blank string value and false part returning length which is numeric data type so we need to have both values of same type.

@juhoneyighot 

Apologies as I should have asked earlier, but what exactly are you trying to accomplish? Can you present a sample dummy data?

@tamerj1 

I have this "JobType column" in Column F see screesnhot below

juhoneyighot_0-1699015349209.png

Lets say it's NC 110_Estimates__70RF Final Billing. I have to get how many characters from that text until Phase_. Estimates which is the phase then _. So the Phase _ for here is 17 which is the total character of this (NC 110_Estimates_)

 

I hope I don't give you confusion on this.

@juhoneyighot 
Maybe somthing like this?

1.png

 

# of _ = 
VAR Length = 
    LEN ( 
        PATHITEM ( 
            SUBSTITUTE ( stx__legacy_fsjob[_JobType_txt], "__", "|" ),
            1
        )
    ) + 1
RETURN
    IF ( Length > 1, Length )

 

 

But why ddo you need this count for in the first plave? What is your ultimate goal?

 

tamerj1
Super User
Super User

Hi @juhoneyighot 
Please try

Phase _ =
IFERROR (
    IF (
        'stx__legacy_fsjob'[# of _] = BLANK (),
        "",
        FIND (
            "~",
            SUBSTITUTE (
                'stx__legacy_fsjob'[_JobType_txt],
                "_",
                "~",
                'stx__legacy_fsjob'[# of _] - 1
            )
        )
    ),
    'stx__legacy_fsjob'[_JobType_txt]
)

@tamerj1 

juhoneyighot_0-1698930426633.png

This error occurs when I tried the formula

@juhoneyighot 
Please try

Phase _ =
IFERROR (
    IF (
        'stx__legacy_fsjob'[# of _] = BLANK (),
        "",
        FIND (
            "~",
            SUBSTITUTE (
                'stx__legacy_fsjob'[_JobType_txt],
                "_",
                "~",
                'stx__legacy_fsjob'[# of _] - 1
            )
        ) & ""
    ),
    'stx__legacy_fsjob'[_JobType_txt]
)

@tamerj1 

juhoneyighot_0-1698933758844.png

Hello! this error occurs.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.