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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Extracting a number from Text

Hi everyone :), I have a column with texts such as " XXXX P10000 7FFFF" , "1BCD R150000" would you please help me to find a formula to extract the 10000 and 150000 after the P and R. They are always either P or R as the begining. Thanks alot.
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Column = 
    VAR __P = FIND("P",[Column1],,BLANK())
    VAR __R = FIND("R",[Column1],,BLANK())
    VAR __Start = IF(ISBLANK(__P),__R,__P) + 1
    VAR __End = FIND(" ",[Column1],__Start,LEN([Column1]))
RETURN
    MID([Column1],__Start,__End - __Start)


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Please do not do this in DAX as it's not a language to shape data and its power to analyze strings is very limited. Such things belong to the data preparation phase and should be performed in Power Query or in the data source.

DAX is a Data Analysis eXpressions language. Not a data mashup engine.

Best
D
Greg_Deckler
Community Champion
Community Champion

Column = 
    VAR __P = FIND("P",[Column1],,BLANK())
    VAR __R = FIND("R",[Column1],,BLANK())
    VAR __Start = IF(ISBLANK(__P),__R,__P) + 1
    VAR __End = FIND(" ",[Column1],__Start,LEN([Column1]))
RETURN
    MID([Column1],__Start,__End - __Start)


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.