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

Modify column with blanks to show the value of a previous cell (with some conditions)

Hello everyone, this is my first time posting here. I've been working for a while with PowerBI and this forum has helped me a lot, so thank you all.

I have the following problem,  I have the following table that relates diferent codes.

The numerical SAP codes have one and only one related Budget code or a Blank Budget code that should keep being Blank.
For the case of alphanumerical SAP codes the ones with the first 9 characters in common should have the same budget code.

 

For example, SAP codes starting with GSD-00397 should have the same Budget code (GTO-TGM-19-03).

 

Budget codeSAP code
GTO-TGM-19-05000000200953
GTO-TGM-19-06000000200968
 000000200989
GTO-TGM-19-03GSD-00397
 GSD-00397-EPC
 GSD-00397-GRAL
 GSD-00397-MAT
GTO-TGM-19-07GSD-00414
 GSD-00414-EPC
 GSD-00414-GRAL
 GSD-00414-MATTGN
GTO-TGM-20-02GSD-00448
 GSD-00448-EPC
 GSD-00448-GRAL
 GSD-00448-MATTGM
GTO-RTI-18-92000000200931

 

What I'm needing is to fill the budget code column with the corresponding budget code for each case.

Having that done, the example above should look like this:

 

Budget codeSAP code
GTO-TGM-19-05000000200953
GTO-TGM-19-06000000200968
 000000200989
GTO-TGM-19-03GSD-00397
GTO-TGM-19-03GSD-00397-EPC
GTO-TGM-19-03GSD-00397-GRAL
GTO-TGM-19-03GSD-00397-MAT
GTO-TGM-19-07GSD-00414
GTO-TGM-19-07GSD-00414-EPC
GTO-TGM-19-07GSD-00414-GRAL
GTO-TGM-19-07GSD-00414-MATTGN
GTO-TGM-20-02GSD-00448
GTO-TGM-20-02GSD-00448-EPC
GTO-TGM-20-02GSD-00448-GRAL
GTO-TGM-20-02GSD-00448-MATTGM
GTO-RTI-18-92000000200931

 

Ps. Considering that the numerical SAP codes with no budget code should remain this way, fill down in the Query editor isn't an option.

 

I know that this can be done easily in Excel but I don't know how to do it in PowerBI.

Thank you in advance.

1 ACCEPTED SOLUTION
davehus
Memorable Member
Memorable Member

Hi, I think this probably could be resolved within query editor. If you have a way of creating a reference table with the budget code and the SAP code. Example 

GTO-TGM-19-03GSD-00397

From there duplicate the SAP Code column and split the "-" as far right as possible. You should be left with the GSD-00397 to match against your reference table and you can merge in the Budget Code. You should be left with a null value where you don't require it.

I've attached a file for you as an example. https://ufile.io/5r60cct9

View solution in original post

2 REPLIES 2
davehus
Memorable Member
Memorable Member

Hi, I think this probably could be resolved within query editor. If you have a way of creating a reference table with the budget code and the SAP code. Example 

GTO-TGM-19-03GSD-00397

From there duplicate the SAP Code column and split the "-" as far right as possible. You should be left with the GSD-00397 to match against your reference table and you can merge in the Budget Code. You should be left with a null value where you don't require it.

I've attached a file for you as an example. https://ufile.io/5r60cct9

dkaushik
Resolver II
Resolver II

Hi @Anonymous 

 

Connect your data to Power BI. 
Then click on "Transform Data" to open power query editor. 
Right click on "Budget Code" column -> Fill -> Down.

dkaushik_0-1620416815967.png

Hope this helps.

 

Please mark as solution if it works out 🙂

 

Thanks,

Dheeraj

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.

Top Solution Authors