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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
matthierry
New Member

How to create a new field taking a variable and filtering it

matthierry_0-1677249614039.png

 

I woul like to create a new value using the field GOO_MAJOR_REFERENCE but filtering it, I just need the data that are located before the "." of the reference. 

How is that possible ? 

Thanks

 

1 ACCEPTED SOLUTION
AmiraBedh
Most Valuable Professional
Most Valuable Professional

When you said the data before "." you didn't precise if it is to the LEFT or to the RIGHT.

You can use the following syntax to create your calculated column : 

NewReference = LEFT('MyTable'[GOO_MAJOR_REFERENCE]FIND("."'MyTable'[GOO_MAJOR_REFERENCE])-1)

 

The error you are getting is related to an extra ) at the end.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

5 REPLIES 5
AmiraBedh
Most Valuable Professional
Most Valuable Professional

Assuming this is the output you want : 

AmiraBedh_0-1677250367925.png

You need to create a calculated column not a measure to achieve your result : 

NewReference = RIGHT('MyTable'[GOO_MAJOR_REFERENCE], FIND(".", 'MyTable'[GOO_MAJOR_REFERENCE])-1)

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Thanks a lot for your feedback, Actually I need the data before the "." so I used left instead, but I get an error. 

 

Is there something i'm doing wrong ? 

 

matthierry_0-1677747423452.png

 

AmiraBedh
Most Valuable Professional
Most Valuable Professional

When you said the data before "." you didn't precise if it is to the LEFT or to the RIGHT.

You can use the following syntax to create your calculated column : 

NewReference = LEFT('MyTable'[GOO_MAJOR_REFERENCE]FIND("."'MyTable'[GOO_MAJOR_REFERENCE])-1)

 

The error you are getting is related to an extra ) at the end.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Sorry, the ")" was a mistake. I typed the right formula but still get an error ... 

 

matthierry_0-1677826478434.png

 

Is there something in the type of data (text, data, ... ) that i need to change ? 

AmiraBedh
Most Valuable Professional
Most Valuable Professional

I reproduced the same thing : 

AmiraBedh_0-1677856017960.png

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.