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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Paulyeo11
Impactful Individual
Impactful Individual

How to fill BRAND_5 = Null with PRO_CLASS first character ?

Hi All

Can some one share with me how to write this expression ?

 

My PBI file :-

https://www.dropbox.com/s/4ysqturttdwcdf4/PB_TDS_V080%20RECODE%20BRAND%20TO%20PROJECT.pbix?dl=0

 

Paulyeo11_0-1606818440683.png

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Paulyeo11 

Try this SWITCH statement

Column 2 = SWITCH(

                    TRUE(),

                    LEN([BRAND_5]) = 0 && LEN([PRO_CLASS]) = 0 , "No Brand",
                    
                    LEN([BRAND_5]) = 0 && SEARCH(" ", SALES[PRO_CLASS], 1, BLANK()) > 0 , LEFT([PRO_CLASS], SEARCH(" ", SALES[PRO_CLASS], 1, BLANK())),

                    LEN([BRAND_5]) = 0 && LEN([PRO_CLASS]) > 0 , [PRO_CLASS],

                    [BRAND_5]

)

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

11 REPLIES 11
PhilipTreacy
Super User
Super User

Hi @Paulyeo11 

Try this SWITCH statement

Column 2 = SWITCH(

                    TRUE(),

                    LEN([BRAND_5]) = 0 && LEN([PRO_CLASS]) = 0 , "No Brand",
                    
                    LEN([BRAND_5]) = 0 && SEARCH(" ", SALES[PRO_CLASS], 1, BLANK()) > 0 , LEFT([PRO_CLASS], SEARCH(" ", SALES[PRO_CLASS], 1, BLANK())),

                    LEN([BRAND_5]) = 0 && LEN([PRO_CLASS]) > 0 , [PRO_CLASS],

                    [BRAND_5]

)

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil

Can you pls help me modify the script , so that it only display 3 Core Brand ?

Paulyeo11_0-1606833633068.png

 

Hi Phil

Thank you very much for your help. it work wonderfull.

Paulyeo11_0-1606831056411.png

 

PhilipTreacy
Super User
Super User

Hi @Paulyeo11 

This will display any single word like MSA from the PRO_CLASS column

Column = IF(LEN([BRAND_5]) = 0 , IF( SEARCH(" ", SALES[PRO_CLASS], 1, BLANK()) = 0 , [PRO_CLASS] , LEFT([PRO_CLASS], SEARCH(" ", SALES[PRO_CLASS], 1, BLANK()))) , [BRAND_5] )

Phil 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil

Many thank it work , pls help me make it display No Brand when PRO_CLASS is empty.

Paulyeo11_0-1606829136699.png

 

PhilipTreacy
Super User
Super User

Hi @Paulyeo11 

This works,

Column = IF(LEN([BRAND_5]) = 0 , LEFT([PRO_CLASS], SEARCH(" ", SALES[PRO_CLASS], 1, BLANK())), [BRAND_5] )

There's a 'feature' with SEARCH (and FIND) that you have to specify the optional 3rd and 4th parameters or it throws an error in certain cases.

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil

Yes it work , But when PRO_CLASS only have MSA , may i know how to pick up this word ?

Paulyeo11_0-1606827982289.png

 

PhilipTreacy
Super User
Super User

Hi @Paulyeo11 

This should work to return the first word from the PRO_CLASS column.  Create a new column and enter this formula

Column = IF(ISBLANK([BRAND_5]) , LEFT([PRO_CLASS], SEARCH(" " , [PRO_CLASS])), [BRAND_5] )

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil, Still same as Amit result :-

Paulyeo11_0-1606826316467.png

amitchandak
Super User
Super User

@Paulyeo11 , Try new column

if(isblank([brand_5]) ,[Pro_class],[brand_5] )

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amit

I have try but when No Brand , it does not take PRO_CLASS field first charater.

Paulyeo11_1-1606819362749.png

 

 

 

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors