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
fashpixie
New Member

LEN Function Not Working with Subtraction

Email = RIGHT(RE_Usage_Data[User],LEN(RE_Usage_Data[User])-3)&"@xyz.com"

Hello!

 

When I entered the function above into the Data view in Power BI, I receive an error stating "An Argument of function 'RIGHT' has the wrong data type or has an invalid view."

 

In piecing the formula apart, it looks like the "-3" is causing the issue.  With this formula, I'm trying to do the following:

 

  • Take a column of text formatted like this: ar/john.b.smith

          and return the following:

 

  • john.b.smith@xyz.com

 

The RE_Usage_Data[User] field is formatted as text - I'm thinking Power BI is not liking that I'm subtracting 3 from the ar/john.b.smith text.  However, based on how this formula is structured, it should be taking the LEN value of 15 and subtracting 3.  12 should be in the RIGHT formula as the number of characters, and no errors should be returned.  I'm also able to replicate this formula in Excel with no issues - it's also worked in other Power BI files.  

 

Is there anything I can adjust in my formula or any other workarounds to get rid of this error?

 

Thanks for the help! 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

The issue is you have a value with 3 or less characters somewhere in your list.  Try this formula instead.

 

Email = Var Length = LEN(RE_Usage_Data[User])
RETURN
IF(
    Length <= 3,
    "",
    right([Name], Length - 3) & "@xyz.com"
)

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

The issue is you have a value with 3 or less characters somewhere in your list.  Try this formula instead.

 

Email = Var Length = LEN(RE_Usage_Data[User])
RETURN
IF(
    Length <= 3,
    "",
    right([Name], Length - 3) & "@xyz.com"
)

Thank you for the help! That worked! Smiley Happy

Greg_Deckler
Super User
Super User

As a measure:

 

Measure 7 = RIGHT(MAX(Email[Column1]),LEN(MAX(Email[Column1]))-3)&"@xyz.com"

@ 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

I don't know, that worked for me as a column, are you trying to do this aas a measure?

 

 


@ 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.