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
mdhevara
Frequent Visitor

ISERROR bug in Desktop Version: 2.79.5768.721

Hello, I am trying to write a simple DAX statement and it fails for some of the values (especially when the values start with a number)

 

TEST = IF (ISERROR(MID(column,1,2)+0),MID(column,1,1), MID(column,1,2))

Sample values, the above solution works for C1A1 however fails for 6A2 and 1A1

C1A1 

6A2

1A1

C3F4

 

Am i missing something (or) is there a bug in ISError

Thanks,

Md

6 REPLIES 6
Greg_Deckler
Super User
Super User

Is this what you were expecting?

 

image.png


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Huh, look at that, 6A is .25... I don't think it is a bug in ISERROR, seems like something else? What are you trying to accomplish?

 

image.png


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg for taking a look. Im trying to return the number before or after the alphabet. So my data can be like below so all i care about is the first 3 characters and if it has numbers return it

Input     Output

23C1    23

2A2       2

A8C1     8

B91       91

BNC     

CHK   

 

This is the DAX code i have it works for everything excet for the 1A6 (or) 2A2 i.e when the number is preceded by the alphabet

 

TEST= IF (ISERROR(MID(column,1,2)+ 0),(IF (ISERROR(MID(column,1,1)+0), (IF (ISERROR(MID(column,2,2)+0), (IF (ISERROR(MID(column,2,1)+0),BLANK(),MID(column,2,1))), MID(column,2,2))), MID(column,1,1))) , MID(column,1,2))

What about this?

 

Column = 
    VAR __1 = IFERROR(LEFT([Input],1)+0,-1)
    VAR __2 = IFERROR(MID([Input],2,1)+0,-1)
    VAR __3 = IFERROR(MID([Input],3,1)+0,-1)
RETURN
    SWITCH(
        TRUE(),
        __1 = -1 && __2 = -1 && __3 = -1,BLANK(),
        __1 <> -1 && __2 <> -1 && __3 = -1,VALUE(__1 & __2),
        __1 = -1 && __2 <> -1 && __3 = -1,__2,
        __1 = -1 && __2 = -1 && __3 <> -1,__3,
        __1 = -1 && __2 <> -1 && __3 <> -1,VALUE(__2 & __3),
        __1
    )

See attached PBIX.

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

Hmm, I will test but on different version:
2.79.5768.1082 64-bit (March 2020)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.