Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi There,
I have an issue to replace values on different columns in a single row based on one condition.
Here, I have continous [date] column and [historic date] column. If date <> histroic date then i want to replace values(to null) of other columns in same row.
Here screenshot of query, Power query advance editor
Error
looking for help @amitchandak @Rickmaurinus
Thanks
PK
Solved! Go to Solution.
1) Change your second each argument to each [Historic Date]
2) Change Replacer.ReplaceValue with (orig, dateVal, histVal) => if dateVal <> histVal then orig else null
3) This will mess up your column types so change them back to normal.
Hello, @pkee
other_columns = List.RemoveItems(Table.ColumnNames(your_table), {"Date", "Historic Date"}),
blanks = Record.FromList(List.Repeat({null}, List.Count(other_columns)), other_columns),
replacer = Table.FromRecords(
Table.TransformRows(
your_table,
(x) => if x[Date] <> x[Historic Date] then Record.SelectFields(x, {"Date", "Historic Date"}) & blanks else x
)
)
1) Change your second each argument to each [Historic Date]
2) Change Replacer.ReplaceValue with (orig, dateVal, histVal) => if dateVal <> histVal then orig else null
3) This will mess up your column types so change them back to normal.
Hello spinfuzer,
It's not working for me. Did i do something wrong?
Thanks
PK
I am not sure here, can you send a small data sample? It is working with examples I am using.
Do you get test for every thing if you do something like
(orig, dateVal, histVal) => "test" instead?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
27 | |
26 | |
23 | |
12 | |
10 |
User | Count |
---|---|
25 | |
21 | |
19 | |
19 | |
11 |