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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Looking to extract only YEARS from specific column

Hello everyone,

Morning!
 

I had a dataset in powerBI, where it looks as follows

 
NumbersExams
1DAX-100-PowerBI-2018-2021
220-DAX-200-PowerBI-2021
3201-DAX-205-powerBI-2019-2020
 
I would like to mention that, every row in Exam's column ends with years and I tried splitting column by delimiter (But, all the data was not in the same format, But all of them ends with years)
 
The result should look like
NumbersExamsYears
1DAX-100-PowerBI-2018-20212018-2021
220-DAX-200-PowerBI-20212021
3201-DAX-205-powerBI-2019-20202019-2020
 
Looking forward for responses.
 
Thank you. 
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, I can clearly understand your requirement, you can try to create a calculated column like this:

Years =

IF(

    ISERROR(left(RIGHT([Exams],6),1)+1),

    RIGHT([Exams],4),

    RIGHT([Exams],9))

And you can get what you want, like this:

vrobertqmsft_0-1635145930751.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, I can clearly understand your requirement, you can try to create a calculated column like this:

Years =

IF(

    ISERROR(left(RIGHT([Exams],6),1)+1),

    RIGHT([Exams],4),

    RIGHT([Exams],9))

And you can get what you want, like this:

vrobertqmsft_0-1635145930751.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , a new column in DAX

 

Year =

var _pos = search("PowerBI-",[Col],,0)

return

right([Column], len([Column] -(_pos+8))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Amit, 

 

sorry, I didn't get what that mean - could you please elaborate the measure and the measure says that we are searching "PowerBI-". But in my case I will have two different types of text either "PowerBI" or "Power flow". 

Thanks Amit.

@Anonymous , I try to get the location of - after power bi and use that.

What you do first check if it has power bi or power flow and the change logic .

 

ALso this a new measure

 

Year =

var _pos = search("PowerBI-",[Col],,0)

return

if(_pos>0, right([Column], len([Column] -(_pos+8)),  right([Column], len([Column] -(_pos+11)) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Amit 

 

I am getting an syntax error.


Thank you so much for following up the error. 

Really appreciated-

 

Thanks 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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