Power Query Replace Values the safer way

  Рет қаралды 23,383

Access Analytic

Access Analytic

Күн бұрын

2 lines of code can save you from having to refer directly to columns and therefore make you refresh more robust in the future.
Whether it's replacing nulls with zeros or any other replacement this technique can help
I refer to a blog article by Gil Raviv around avoiding directly referencing columns when detecting data types: datachant.com/2018/05/14/auto...
Content
00:00 Intro
00:19 The Scenario
01:00 How we do it
03:25 Table.ColumnNames
03:40 Editing Table.ReplaceValues
04:51 Subscribe
Follow me on LinkedIn
/ wynhopkins
Twitter
/ wynhopkins
Access Analytic Blog
accessanalytic.com.au/blog

Пікірлер: 119
@rajeshmajumdar4999
@rajeshmajumdar4999 2 ай бұрын
Thanks a ton!!! I had a situation where I needed to split a column by delimiter ... now I don't know how many columns I may have for numbers ... and all blank columns have nulls ... I just referenced the base query and used your formula... It worked. God bless you.
@AccessAnalytic
@AccessAnalytic 2 ай бұрын
Glad it helped. I appreciate you taking the time to let me know you found it useful
@Bhavik_Khatri
@Bhavik_Khatri 2 жыл бұрын
Bloody marvelous! I'm learning PQ and I was thinking of FirstN function, but your approach is very good. I learnt something new today. Thank you very much.
@garylhaas2005
@garylhaas2005 2 жыл бұрын
I skill don't "grasp" the full power of Lists - but each one of your videos brings me closer
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
It's a slow and steady journey Gary
@GrainneDuggan_Excel
@GrainneDuggan_Excel 3 жыл бұрын
So simple and so very helpful. I am glad to see the intellisense annoyances pointed out. Hopefully they get adjusted soon
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Cheers Grainne
@joescanlonh1365
@joescanlonh1365 Жыл бұрын
Nice, exactly what I have been dealing with hitting refresh and broken headers. Thank you.
@AccessAnalytic
@AccessAnalytic Жыл бұрын
You're welcome. Thanks for taking the time to leave a comment
@DancingZeliha
@DancingZeliha 2 жыл бұрын
That was awesome. I am glad I watched it even though it wasn't quite addressing the issue I was researching. I was certainly rewarded with some very helpful and useful tips. Thank you.
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Glad to help. What were you looking for specifically?
@jazzista1967
@jazzista1967 3 жыл бұрын
very elegant solution
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Thank you
@antoniogarrido3058
@antoniogarrido3058 3 жыл бұрын
Brilliant.! Really useful and applicable solution for a usual problem... , thanks!!
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Thanks for taking the time to leave a comment Antonio. 👍🏼
@doviedk
@doviedk Жыл бұрын
That was awesome! Nice explanation of the steps required.
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Thanks for taking the time to leave a kind comment
@lukesteen157
@lukesteen157 3 жыл бұрын
Awesome tip! Thank you!
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Great, glad you liked it
@danielgalloecheverri2770
@danielgalloecheverri2770 3 жыл бұрын
Excellent tip, thank you so much!!!
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Cheers Daniel, thanks for letting me know you liked it
@brunof.s.8186
@brunof.s.8186 2 жыл бұрын
Casually watching KZbin tutorials and stumbled to yours. Check my data, check your video.... BANG! Just put it into the data set I was working with. Super thanks!
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
That's great Bruno! Thanks for letting me know
@singhalmonica
@singhalmonica 2 жыл бұрын
Great video, as always
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Thanks Monica
@VikingGuard
@VikingGuard 3 жыл бұрын
Love this little trick. Handy in when one is sourcing Rest api from all sorst of webservices.
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Thanks for letting me know you found it useful VikingGuard
@yousefissa100
@yousefissa100 Жыл бұрын
so lovely and useful
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Thanks for the kind comment
@EricaDyson
@EricaDyson 2 жыл бұрын
Gerat. Really useful for me.
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Glad it helped Erica
@ImranHussain-xv4se
@ImranHussain-xv4se 2 жыл бұрын
Great video
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Thanks Imran
@biljanamajstorova3332
@biljanamajstorova3332 2 жыл бұрын
Power query is so unlimited with options, and there is no right or wrong way to clean the data. For this particular goal i would unpivot other columns, apply the replace null to zero, and than pivot again. We'll receive the same result🙂 Usualy when cleaning data i apply more than one changes to the values from the source data, like change data type for value columns, divide with 1000 to receive k values, or convert to Fx, rounding, merge with lookup table and so on...than pivot again if output is needed in columns. Like the opt you show since it is a step forward to understand better the M language and utilize when there is no "button" to apply complex transformations 🙂
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Absolutely Bilijana. So many options. One thing to note is that unpivotting removes nulls so there would be nothing to replace hence my approach here.
@jorstube
@jorstube 3 жыл бұрын
Very helpful...Thank's
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Thank you Jorge
@Luciano_mp
@Luciano_mp 3 жыл бұрын
Useful. Thanks!
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Cheers Luciano
@MichaelBrown-lw9kz
@MichaelBrown-lw9kz Жыл бұрын
This is awesome. Wow
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Glad you like it!
@bashirmoustafa6116
@bashirmoustafa6116 3 жыл бұрын
Awesome,,, thank you 👍
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
You’re welcome Bashir. Thanks for the comment
@shadrackawunyo7786
@shadrackawunyo7786 3 жыл бұрын
Beautifully done sir. Very applicable in a variety of scenarios
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Cheers Shadrack, I appreciate your comment
@davidferrick
@davidferrick 3 жыл бұрын
Agreed, was just going to state the same thing.
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
@@davidferrick Thankyou!
@AndreTMaciel
@AndreTMaciel 3 жыл бұрын
great content!
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Cheers André
@khalidmijhad5747
@khalidmijhad5747 2 жыл бұрын
So many hours of work I would have saved if I new this before
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
This happens to us all Khalid 😀
@alicemorili1330
@alicemorili1330 2 жыл бұрын
This is awesome
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Thanks Alice
@gborka
@gborka 2 жыл бұрын
Cool. Thank you a lot.
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
You’re welcome Boris
@felipesignorellireis7839
@felipesignorellireis7839 2 жыл бұрын
very good
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Thanks Felipe
@paspuggie48
@paspuggie48 3 жыл бұрын
Lovely tip :)
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Thank you Paul
@raramaeja884
@raramaeja884 Жыл бұрын
amazing
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Cheers
@johnhackwood1568
@johnhackwood1568 Жыл бұрын
Nice, thanks :)
@AccessAnalytic
@AccessAnalytic Жыл бұрын
You’re welcome
@JonathanExcels
@JonathanExcels 3 жыл бұрын
Useful
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Thanks
@julie_chen
@julie_chen Жыл бұрын
👍
@Simon-vc1wk
@Simon-vc1wk Жыл бұрын
Nice Tip. Another thought, what happens if the position of the range changes can this be updated dynamically for the import.
@AccessAnalytic
@AccessAnalytic Жыл бұрын
If the Excel data isn't in a named range or table and the "block" of data moves then Power Query may or may not pick that up automatically. If extra data has been added above or to the left of the block then things will likely get tricky / fail
@FRANKWHITE1996
@FRANKWHITE1996 3 жыл бұрын
its a kind of magic!!! :D
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
Cheers FrankWhite
@rrrraaaacccc80
@rrrraaaacccc80 10 ай бұрын
💯👍
@sabarashid1513
@sabarashid1513 Жыл бұрын
Hi Wyn, thank you for sharing all the tips and tricks around Power Query. I have a problem slightly different - what if I want to replace all the non-null values with 1 multiple column. As we do in excel find * replace 1. Don't want to add helper columns to achieve this.... Can you please guide. Thanks again
@AccessAnalytic
@AccessAnalytic Жыл бұрын
You could do a Transform to Multiply all values by 0 then replace the 0s? Would that work for you?
@ohhhnelly203
@ohhhnelly203 Жыл бұрын
Excellent video! Instead of hard coding the original and replaced values (null and 0 in this example) in the formula, how can you replace values referencing a 2 column table in another query?
@AccessAnalytic
@AccessAnalytic Жыл бұрын
You can right-click “drill down” on the values you need to turn them into “parameters” and the use those named parameters instead of the hard coded values
@Psyresidente
@Psyresidente 2 жыл бұрын
Great video. How can I replace multiple different strings from a column in one step ? I'm trying to find this solution but is nowhere.
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Thanks, does this help? chandoo.org/wp/multiple-find-replace-list-accumulate/ or this www.howtoexcel.org/bulk-replace-values/
@kingLostSouls
@kingLostSouls Жыл бұрын
Will this work with an SQL Query ? so with every refresh will the function run to find any new null and replace with what was designated?
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Yep regardless of how the data is connected to the Power Query steps are then the same and will rerun each refresh
@txreal2
@txreal2 2 жыл бұрын
I'm delighted to have subscribed & learned from your videos. I've been troubled with repeating the steps of replacing "(", " )", and "-" in home, work, and mobile phone # columns individually (3x3) in my csv. Is there a way to applied those 3 steps to those 3 columns in one sweep? Thanks.
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
If you select the 3 columns ( holding Ctrl ) then do the 3 replace values then you should be good. There’s no real need to do it one step
@txreal2
@txreal2 2 жыл бұрын
@@AccessAnalytic Thanks!
@robrayborn1349
@robrayborn1349 Жыл бұрын
A most excellent demonstration! How would this work when using data from File, from Folder, where the columns of data in the files may be different dates? Also while bringing in the 'Date created' from the file?
@AccessAnalytic
@AccessAnalytic Жыл бұрын
You would need to Unpivot Other Columns in the Transform Sample file when consolidating to allow you to stack a single date column on top of each other. Within the Remove Other Columns step you could maybe see if Date Created is one of the removed columns and then change the code not to remove it.
@robrayborn1349
@robrayborn1349 Жыл бұрын
@@AccessAnalytic Thank you. I'll give it a go.
@defaultHandle1110
@defaultHandle1110 3 жыл бұрын
Okay now instead of null, how can I replace everything < 0 with 0. I would like to dynamically replace all values under 0 (nagtives should be zero).
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
I’d go with adding a conditional column and then remove the original column
2 жыл бұрын
Marvelous!. Thank you. And now a challenge. I have a table with n months how heading. They store the amount of product to buy. I have a price column per product. I want to replace the monthly quantity columns with values multiplying each column of (amount month) * price. Without creating additional columns. The quantity and names of the columns is dynamic. What do you think?
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Hi Huber, maybe a combination of Unpivot, and merge. Difficult to say without seeing the data. I'd suggest you post a few screenshots and if possible a dummy file here: aka.ms/excelcommunity or community.powerbi.com/
@irenegurne8953
@irenegurne8953 Ай бұрын
Thanks but im thinking on how about changing a value of a record, depending on the seach condition, say i want to change the date of inv215? how would you do the seach , then change the date without creating additional column?
@AccessAnalytic
@AccessAnalytic Ай бұрын
Not sure off the top of my head. Any particular reason you want to avoid adding a column temporarily?
@engahmedelbendary1566
@engahmedelbendary1566 2 жыл бұрын
thx alot and i hope to explain how to Skip rows empyty rows dynamicaly and remove columns that i donot neet easly way
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Hi Ahmed There’s a remove blank rows button, and use the choose columns button to deselect columns you don’t need
@waynekranz7813
@waynekranz7813 Жыл бұрын
Have you explored if DAX Measures built referencing “original” column names, would still suffer model breaking on refresh where the Headers List has changed?
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Power BI measures should update to reflect the new column names (e.g. if you have a measure = SUM( SalesData[Sales Value]) and in Power Query you rename the column from Sales Value to Sales $ Column, the measure will update to reflect this.
@waynekranz7813
@waynekranz7813 Жыл бұрын
@@AccessAnalyticSince watching I have had an opportunity to test that renaming intelligence of column names referenced in Measures do indeed carry through, even where a power Query table references a different source table in the model, where that original table has a header change. Brilliant assurance. Thanks for quick response and for years of quality video content. I’m currently enjoying working my way through your entire back catalogue on this channel for extra tips and gems.
@AccessAnalytic
@AccessAnalytic Жыл бұрын
@@waynekranz7813 - excellent. Don't judge me on the sound quality in earlier videos!
@txreal2
@txreal2 Жыл бұрын
Would you have time to do a Power Query Bulk Replace Values video? I've seen some other videos. However, I believe you may have a more elegant solution or less steps. ✌
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Noted
@rafal2934
@rafal2934 Жыл бұрын
Can I use it if I have other steps like Navigation and Promoted Headers? because its not really working for me
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Yes. Navigation and promote headers do not reference columns ( in the formula bar ).
@murtazaiqbal7267
@murtazaiqbal7267 Жыл бұрын
How can we replace values with wild card in power query.? e.g. if Any thing starts with "Product" will replace with null. Only values which starts with "Product".
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Maybe add a custom column with this: =if Text.StartsWith( [ColumnOfWords],"Product") then Text.Replace([ColumnOfWords],"Product","") else [ColumnOfWords]
@vernonlasrado
@vernonlasrado 3 жыл бұрын
That’s a wonderful code 👍 Is there any easier quick fixes for cleaning up the description field in bank statement that have multiple combinations of transaction ID, payee name, biller name etc?
@AccessAnalytic
@AccessAnalytic 3 жыл бұрын
That’s difficult to answer without fully understanding the scenario . Maybe this will help? kzbin.info/www/bejne/r4nbeaR6Z9VpgKc
@ExcelWithChris
@ExcelWithChris Жыл бұрын
Are these files available for download? Would like to demo to my students. Greetings from South Africa.
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Hi, not this one sorry. I’ve started including files with more recent videos
@kuldar.
@kuldar. 2 жыл бұрын
Greate video, Sir! I have a huge problem - tried to find solution but without any luck. I have merged query with inserted columns that include hard coded values. Every time after refreshing the query all inserted values have gone. Is there some way to keep these values after data refresh?
@AccessAnalytic
@AccessAnalytic 2 жыл бұрын
Thanks Kuldar86, if you are adding manual values to the table that has been loaded into the Excel worksheet then each time you refresh these will be replaced or at best show up in the wrong position and this should be avoided. Matt Allington does showcase a possible technique here exceleratorbi.com.au/self-referencing-tables-power-query/
@kuldar.
@kuldar. 2 жыл бұрын
@@AccessAnalytic Thank you very much! I will check and hopefully find solution.
@agustriyono
@agustriyono Жыл бұрын
Hello, nice video. i want to replace null values and blank in power query, but i don't know the data type. the data type is any. so if i used right click and then the replace values is off.
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Change to text if not sure what the data type is going to be
@agustriyono
@agustriyono Жыл бұрын
@@AccessAnalytic if i change to text, is there will be any problem with the data? .
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Everything in that column will be treated as text, even numbers. So you won’t be able to add those numbers or do calculations with them.
@agustriyono
@agustriyono Жыл бұрын
@@AccessAnalytic thank u , appreciate. Example my data : 3/32, 4/64, 12/1TB, any blank and null values.
@AccessAnalytic
@AccessAnalytic Жыл бұрын
That will be fine as Text
@Simon-vc1wk
@Simon-vc1wk Жыл бұрын
Pity tables in model doesn't have the same option as in Excel Pivot to replace nulls with 0
@AccessAnalytic
@AccessAnalytic Жыл бұрын
Yep, although you can do that with the Pivot Table output from the model
Beware  using .XLS files as a Power Query data source
5:43
Access Analytic
Рет қаралды 13 М.
Power Query - Avoid "Helper Queries" (+10 Cool Tricks)
18:40
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 52 МЛН
Пробую самое сладкое вещество во Вселенной
00:41
KINDNESS ALWAYS COME BACK
00:59
dednahype
Рет қаралды 119 МЛН
Did you believe it was real? #tiktok
00:25
Анастасия Тарасова
Рет қаралды 49 МЛН
How to Rename Column Headings with Power Query - the quick automated way
11:31
Insert Blank Row for each change in a value using Power Query
10:18
Access Analytic
Рет қаралды 34 М.
Power Query - Bulk Replace Values in One Step 🔄📊
4:22
BA Sensei
Рет қаралды 3,6 М.
Multiple Find / Replace with List.Accumulate() ~ Power Query
19:24
Dynamically Re-Order Columns in Power Query
7:57
Goodly
Рет қаралды 14 М.
35 million watched superman video
0:13
Hasan Kaval
Рет қаралды 245 МЛН
#londonbridges
0:14
J House jr.
Рет қаралды 9 МЛН
Smart Appliances! New Gadgets, Versatile Utensils, Tool Items #shorts #gadgets 73
0:30
路飞被小孩吓到了#海贼王#路飞
0:41
路飞与唐舞桐
Рет қаралды 29 МЛН