Power Query : Replace value with 0 based on criteria name "Mercy"

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,102
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all.

how replace value with 0 in col Amount based on col. Model
i want replace value for Mercy with 0
like this table
Book1
ABCDEFGHI
1original dataafter using Power Query
2RegionModelDateAmountRegionModelDateAmount
3HongkongBMW01/03/202210HongkongBMW01/03/202210
4HongkongBMW01/04/202210HongkongBMW01/04/202210
5HongkongBMW01/05/202210HongkongBMW01/05/202210
6HongkongBMW01/06/202210HongkongBMW01/06/202210
7HongkongBMW01/07/202210HongkongBMW01/07/202210
8HongkongBMW01/08/202210HongkongBMW01/08/202210
9HongkongBMW01/09/202210HongkongBMW01/09/202210
10HongkongBMW01/10/20225HongkongBMW01/10/20225
11HongkongBMW01/11/20224HongkongBMW01/11/20224
12HongkongBMW01/12/20225HongkongBMW01/12/20225
13MalayMercy01/03/202211MalayMercy01/03/20220
14MalayMercy01/04/202212MalayMercy01/04/20220
15MalayMercy01/05/202213MalayMercy01/05/20220
16MalayMercy01/06/202220MalayMercy01/06/20220
17MalayMercy01/07/202220MalayMercy01/07/20220
18MalayMercy01/08/202220MalayMercy01/08/20220
19MalayMercy01/09/202220MalayMercy01/09/20220
20MalayMercy01/10/20220MalayMercy01/10/20220
21MalayMercy01/11/20220MalayMercy01/11/20220
22MalayMercy01/12/20220MalayMercy01/12/20220
Sheet1


thanks in advance

susant
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
New conditional column: If Model equals Mercy then 0 else column Amount. Then delete old Amount column and rename the new column.

1667064633083.png
 
Upvote 0
hi Automatrix...
like my sample in column I "Amount" Model "BMW" after using PQ, should be contains numbers from adjacent column
here screenshot after using your formula
 

Attachments

  • mercy_problem.jpg
    mercy_problem.jpg
    140.2 KB · Views: 16
Upvote 0
hi Automatrix...
like my sample in column I "Amount" Model "BMW" after using PQ, should be contains numbers from adjacent column
here screenshot after using your formula
Change the dropdown under the word "Else" from "Enter a value" to "Select a column". Then select the Amount column.
 
Upvote 0
You can actually achieve this inside the column.
Power Query:
Table.ReplaceValue(PreviousStep, each [Amount], each if [Model] = "Mercy" then 0 else [Amount],Replacer.ReplaceValue, {"Amount"})

I'm without Excel so I hope I got all of the syntax right.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top