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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ifillingham
Frequent Visitor

Replace values in a column based on values in a different column

I wonder if someone can help me.

 

I have a table of student information in Power query with the following layout:

 

Year GroupSubject Code
10Ss
11Ss
12Ss
13Ss
11Pe
12Ss
13Ss
10Pe

 

I would like to change the Ss values in the "Student Group" column to Pe BUT only if the Year group is 12 or 13. I have spent quite a while trying to find a solution (ideally a single step) but I haven't been successful.

 

The ideal outcome would be (based on the above data) - i.e. only the bold values have been changed.

 

Year GroupSubject Code
10Ss
11Ss
12Pe
13Pe
11Pe
12Pe
13Pe
10Pe

 

I would really appreciate it if anyone had any ideas and could help me out.

Thanks so much,

Ian

1 ACCEPTED SOLUTION
ifillingham
Frequent Visitor

I've found the solution so wanted to close this before anyone commented!!

 

I created a custom column:

 

Table.AddColumn(#"Capitalized Subject code", "Change KS5 Ss to Pe", each if [Subject Code] = "Ss" and [YearCode] >= 12 then "Pe" else [Subject Code])

 

"Capitalized Subject code" and  "Change KS5 Ss to Pe" refer to parts of the puery to make it easier for mne to follow what I did so I can do it again if I need to!!

View solution in original post

1 REPLY 1
ifillingham
Frequent Visitor

I've found the solution so wanted to close this before anyone commented!!

 

I created a custom column:

 

Table.AddColumn(#"Capitalized Subject code", "Change KS5 Ss to Pe", each if [Subject Code] = "Ss" and [YearCode] >= 12 then "Pe" else [Subject Code])

 

"Capitalized Subject code" and  "Change KS5 Ss to Pe" refer to parts of the puery to make it easier for mne to follow what I did so I can do it again if I need to!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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