Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
hi,
following is a situation i'm in
1. i hv 2 columns called 'Category' & 'Item';
2. i have a situation where for each condition where Category-column contains "School Fees", each corresponding Item-column ietm is blank;
3. so, i need to replace each blanks in the Item-column with "School Fees" for each cases where Category-column contains "School Fees";
4. lastly, i need for each cases where Category-column contains "School Fees", it will be replaced with "Fees"
5. finally, you won't have any blanks in the Item-column since they have been replaced with "School Fees" + for the Category column, there won't b "School Fees" anymore since it has also been replaced with "Fees".
i'd appreciate any help to write a power query for this.
tks & krgds, -nik
Solved! Go to Solution.
Hi Nik ,
The first one you want to replace is [Item] as this depends on [Category] being "School Fees", so:
-1- Right-click on a null value in the [Item] column and select 'Replace Values...'. In the 'Replace With' box, type "School Fees". This will auto-generate code for you like this:
-2- Adjust the highlighed section above so it looks like this instead:
-3- Now you've done this bit, you can just right-click on a "School Fees" value in your [Category] column, select 'Replace Values...' again, and replace with "Fees".
Output:
Full example query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk7OyM/PUXBLTS1W0lFSio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Item = _t]),
repBlankNull = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Item"}),
// Relevant steps from here ---->
repItem = Table.ReplaceValue(repBlankNull, null, each if [Category] = "School Fees" then "School Fees" else null, Replacer.ReplaceValue,{"Item"}),
repCategory = Table.ReplaceValue(repItem,"School Fees","Fees",Replacer.ReplaceText,{"Category"})
in
repCategory
Pete
Proud to be a Datanaut!
many tks, @BA_Pete.
as there r also similar instances where Category = Donations & Items is blank, i have managed to use & modify that power query script you gave & correct the previous errors succesfully.
tks & krgds, -nik
Hi Nik ,
The first one you want to replace is [Item] as this depends on [Category] being "School Fees", so:
-1- Right-click on a null value in the [Item] column and select 'Replace Values...'. In the 'Replace With' box, type "School Fees". This will auto-generate code for you like this:
-2- Adjust the highlighed section above so it looks like this instead:
-3- Now you've done this bit, you can just right-click on a "School Fees" value in your [Category] column, select 'Replace Values...' again, and replace with "Fees".
Output:
Full example query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk7OyM/PUXBLTS1W0lFSio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Item = _t]),
repBlankNull = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Item"}),
// Relevant steps from here ---->
repItem = Table.ReplaceValue(repBlankNull, null, each if [Category] = "School Fees" then "School Fees" else null, Replacer.ReplaceValue,{"Item"}),
repCategory = Table.ReplaceValue(repItem,"School Fees","Fees",Replacer.ReplaceText,{"Category"})
in
repCategory
Pete
Proud to be a Datanaut!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 10 | |
| 6 | |
| 5 | |
| 4 | |
| 3 |