Replace Values Based on Condition (in a Single Step) in Power Query

Поделиться
HTML-код
  • Опубликовано: 1 авг 2024
  • This video teaches how you can replace values based on a condition. All in a single step! You can for example replace all negative numbers by 0, and leave the remaining numbers untouched. In addition, this method allows you to easily replace values based on another column.
    WRITTEN BLOGPOST:
    The ultimate guide to replacing values in Power Query, find it here:
    gorilla.bi/power-query/replac...
    Master Functions and Syntax in M
    powerquery.how
    If you want to learn how to do this for multiple columns, check out my other video: • Replace Values in Mult...
    Chapters:
    00:00 Introduction
    00:16 The dataset
    00:40 Creating a temporary helper column
    01:21 Replace values based on a condition
    ABOUT BI Gorilla:
    BI Gorilla shares videos and articles on Power BI and Excel to help you improve your skills.
    SUPPORT MY CHANNEL
    Any videos are made free of charge. You can support my channel by giving a donation through: paypal.me/rickmaurinus.
    Website: gorilla.bi
    SUBSCRIBE TO MY CHANNEL
    ruclips.net/user/bigorilla?sub_con...
    LET'S CONNECT:
    Blog: gorilla.bi
    Facebook: / bigorilla
    Twitter: / rickmaurinus
    LinkedIn: / rickmaurinus
    Thank you for your support!
    #ConditionalReplace #PowerQuery #BIGorilla

Комментарии • 146

  • @user-cz8yx7lq1e
    @user-cz8yx7lq1e 5 месяцев назад +12

    Man! You saved me when ChatGPT and Copilot could not help, even in a task that seemed to be so simple.
    Very thanks!

  • @xyz123770
    @xyz123770 4 месяца назад +1

    Thanks a ton for explaining that so clearly. I especially appreciate the elegance of doing it all in one step. Bravo!

  • @milossubak8909
    @milossubak8909 2 года назад +4

    Simple, elegant, and well explained. Thanks!

  • @RaisingBrows
    @RaisingBrows 2 года назад +7

    This video was so helpful! Exactly what I was looking for. I used criteria based on multiple fields for different scenarios. I used Each only once before the start of the if statements and it worked perfectly. Thank you!!!

  • @carolineabrahamsson9107
    @carolineabrahamsson9107 Год назад +1

    Thank you for a great explanation and solution!

  • @CAKimberlyLewis
    @CAKimberlyLewis 2 года назад +1

    @BIGorilla comes through again (and again and again)! Thank you SO much!

    • @BIGorilla
      @BIGorilla  2 года назад

      🚀 Thanks Kimberly! glad to help

  • @stuartproctor6051
    @stuartproctor6051 Год назад +1

    Absolutely brilliant, this has saved my so much time and head-scratching! Thank you 🙂

    • @BIGorilla
      @BIGorilla  Год назад

      Cheers Stuart. This can be tricky !

  • @PeteMackay
    @PeteMackay 2 года назад +1

    Thanks, great explanation and very helpful.

  • @ahmadahmadsalim7023
    @ahmadahmadsalim7023 Год назад +1

    This was really helpful. Thank you so much.

  • @adyelencu
    @adyelencu 4 месяца назад

    Man, you just helped me with this week's work. So nicely explained, cheers!

  • @moyura2
    @moyura2 2 года назад +1

    Good explanation make it easy to understand, thanks for sharing.

  • @russomarta9059
    @russomarta9059 Год назад

    Thanks so much from Napoli !!

  • @evelic
    @evelic Год назад

    Thank you. Just what I was looking for.

  • @huseyinburaktasci1638
    @huseyinburaktasci1638 5 месяцев назад +2

    wow! what a solution. Thanks a lot!!

  • @ThiagoGSilva
    @ThiagoGSilva Год назад

    Nice, direct and clear

  • @lubomirjagersky7327
    @lubomirjagersky7327 2 года назад +1

    Helpful and very good explained. Thank you.

  • @Soulenergy31
    @Soulenergy31 2 года назад +1

    Neat and wise approach, thx a bunch!!

  • @walkurey
    @walkurey Год назад

    Brilliant mate, this helped me so much. I have googled so much about this subject and couldn't find an easy way to do this, untill I stumbled upon your tutorial. Thanks!

    • @BIGorilla
      @BIGorilla  Год назад

      Thanks Esther. There's an accompanying article where I explain some: gorilla.bi/power-query/replace-values/

  • @w13ken
    @w13ken 2 года назад +1

    Chef's kiss for this one Rick 🙂 I wish the Power Query UI options for updating columns were as good as for adding columns but this is a great explanation and helped me out. Subscribed!

    • @BIGorilla
      @BIGorilla  Год назад

      Thanks, great to hear that helped!

  • @philipedesouzasantos1201
    @philipedesouzasantos1201 2 года назад +1

    Thank you mate, it was a big help to resolve an annoying bad clusterization problem (and ofc it saved me a lot of hours of research)

    • @BIGorilla
      @BIGorilla  2 года назад +1

      Ofcourse, and thanks for tuning in to the channel. Great to hear you managed to solve your clusterization problem.
      ^^ Rick

  • @suki9860
    @suki9860 2 года назад

    Simply Magic, Rick! Thanks!

  • @mnowako
    @mnowako 2 года назад +1

    Awesome trick! Thank you.

  • @yasinwarsame3282
    @yasinwarsame3282 2 года назад +2

    I am so pleased with how you explain and teach! Thank you! I have subscribed and liked the video!

    • @BIGorilla
      @BIGorilla  2 года назад

      WOW WOW WOWWW. Thank you so much for the support. It is highly appreciated. Thanks for coming to my channel!
      Rick

  • @mdmizanurrahman2914
    @mdmizanurrahman2914 2 года назад

    This is really helpfull! exactly i wanted to learn. thank you so much !

  • @users-9pR2s7
    @users-9pR2s7 Месяц назад

    That was exactly what I was looking for! Thank you 🙏

  • @nelson_k_d
    @nelson_k_d 2 года назад +1

    Thanks Man you are awesome, great way of presentation!

  • @mapi55555
    @mapi55555 2 года назад

    Awesome explanation.

  • @Easy_crafts_fr_u
    @Easy_crafts_fr_u Год назад +1

    Useful. Thank you👍

  • @mhd2hamad
    @mhd2hamad Год назад

    very helpful. many thanks

  • @mariangelesavalos9130
    @mariangelesavalos9130 9 месяцев назад

    Me salvaste la vida, gracias por tu video!

  • @tantewalla
    @tantewalla 2 года назад +1

    This is BEAUTIFUL! Thanks dude, this vid helped a bunch!

  • @omidgharipour6974
    @omidgharipour6974 2 года назад +1

    I love it. Thank You for making this video.

    • @BIGorilla
      @BIGorilla  2 года назад

      Thanks Omid. I'm glad it helps, more useful content is scheduled to release soon. If you wanna keep track, subscribe 😎🔥

  • @balrajvirdee1087
    @balrajvirdee1087 4 месяца назад

    Thanks so much, this is an amazing tip, very useful, was looking how to do this for ages. 👍🏽👍🏽👍🏽👍🏽👍🏽👍🏽

  • @050224011
    @050224011 2 года назад

    Very Clever, thank you

  • @andyle1256
    @andyle1256 2 года назад +10

    Note to self: To skip a line in the formula bar, press "Shift" + "Enter"

  • @Sangram2031
    @Sangram2031 11 месяцев назад +1

    Awesome solution bro🎉

  • @steveschouten
    @steveschouten Год назад

    Awesome Rick!

  • @arne.munther
    @arne.munther Год назад

    Thank you.
    I like to do a bulk replacement, based on table (excel) with two columns, A (numbers) and B (text).
    If the value of Number columns is equal to a value in column A, then replace the text in another columns, with text from columns B.

  • @DavesMegaBeats
    @DavesMegaBeats 9 месяцев назад

    Thanks great video

  • @fajnefajne4339
    @fajnefajne4339 Год назад

    That is a fantastic trick. I have just used it. Thank you Rick! ;-)

    • @BIGorilla
      @BIGorilla  Год назад +1

      Great Fajne, glad it worked!

  • @samyoung6331
    @samyoung6331 Год назад

    Oh my gosh. Why WHY DID I NOT WATCH THIS YEARS AGO!!!

  • @stevedepeijper5054
    @stevedepeijper5054 2 года назад

    Nice one!

  • @kyleropp6634
    @kyleropp6634 Год назад

    Thanks!

  • @anthonyaroni5530
    @anthonyaroni5530 2 года назад

    Awesome content!👍

    • @BIGorilla
      @BIGorilla  2 года назад

      Thank you Anthony! Glad you like it 😁

  • @10ozGold
    @10ozGold 2 года назад

    Excellent video. The single step code is very helpful. How would you modify the code that can query against another wild keyword From To table?

  • @user-iw6tq9nq9h
    @user-iw6tq9nq9h Год назад

    Very helpful video! You are a genius. Liked ans suscribed!

  • @andresjustinianod.7067
    @andresjustinianod.7067 2 года назад

    Thanks

  • @wowagt4589
    @wowagt4589 6 месяцев назад

    I love you for this

  • @smahmudmobin
    @smahmudmobin 9 месяцев назад

    Great video. How do you show the bar below the header withValid, Error, Empty status? Thank you!

  • @smartwork4768
    @smartwork4768 2 года назад

    Amazing

  • @rahulbhanushali5278
    @rahulbhanushali5278 Год назад

    Great video, but what if I want to replace values based on matching condition of certain column values to column values from another table. (Like how we create relationships using keys)?

  • @philkrohn6335
    @philkrohn6335 4 месяца назад

    Great video! Is there any way to replace the values in various columns and not just one and each with the same condition?

  • @patrickpalombo
    @patrickpalombo Год назад +1

    I want to click a button and set cell value in a block from B3:H60 to “0” ONLY if the corresponding row cell in column A has a value(is not null)
    And I cannot figure this out to save my life. Can you help?

  • @joncue0304
    @joncue0304 3 месяца назад

    How would you cycle through another table to determine the values to lookup and replace? I've seen the list.accumulate, however it did not work in my use case. Is there another way to do this?

  • @christopherskyap8985
    @christopherskyap8985 Год назад

    Hi Gorilla Sir, Great Video
    I was trying to apply to multiple columns but cannot get it work
    Table.ReplaceValue(#"Change Type:,
    each {[Value1], [Value2]},
    each if [Name] = "Tommy" then "Replaced" else {[Value1], [Value2]},
    Replacer.ReplaceValue, {"Value1", "Value2"}

  • @shashankchandramouli34
    @shashankchandramouli34 2 года назад

    i am doing dashboard for animals dataset, there is a column named threats , in that column the values are sentences , like " The major threat is deforestation ...." ,i want to replace these kind of sentences to one word like " deforestation " based on condition like if the row value contains this word then change it to another word . is it possible to that ?

  • @user-zr5xc5xk1j
    @user-zr5xc5xk1j Год назад

    I have query
    I have made a list of column which contains TDS in their heading.
    Now I want to create a Column where it checks the column from this list for current row that if any column from this list is not null for the row then take the heading of the column from the list in the created column, if all column are null then take null .

  • @pkuchnicki
    @pkuchnicki Год назад

    Rick, love you useful youtube videos! Just went through your 150 text function examples and by far it is the most practical stuff I have seen on M code. But, I am not seeing something I believe exists in other languages, checking for a blank value. I see cells in a row which are not null and I would like to test for it, but I am not seeing a way to do it. Am I missing something?

    • @BIGorilla
      @BIGorilla  Год назад

      Hey Peter. Bit late to the party. So you're looking to test if something is blank. Perhaps I'm misunderstanding but have you tried a statement like:
      if [SomeColumn] = null then "null" else "non-null"

  • @krishnamurthy1945
    @krishnamurthy1945 2 года назад +1

    Thank you for sharing knowledge. Could you give more details on how to generate IndexYearMonth column ,

    • @BIGorilla
      @BIGorilla  2 года назад +1

      Hi Krishna,
      I appreciate the support. To answer your question. The topic of an IndexYearMonth column was not mentioned in this video, but can be useful for time intelligence purposes.
      To create one:
      1. Group your data in Power Query by Year and Month, and as aggregation select 'All Rows'.
      2. After clicking OK, go to 'add column' and add an Index Column.
      3. Since you clicked All Rows in step 1, you still have table objects available on each line. Expand the column with table objects by selecting the arrows in the right-top of the column.
      You have now created the YearMonth Index column. Hope it helps!
      Rick

    • @krishnamurthy1945
      @krishnamurthy1945 2 года назад

      @@BIGorilla Thank you Rick. actually i am doing the order by for the last 12 months. having data like Feb-20 , Jan-21 ,... etc.

    • @BIGorilla
      @BIGorilla  2 года назад

      Hi @@krishnamurthy1945, that's perfectly fine. Is there a question or can go forward with it?

  • @vashisht1
    @vashisht1 2 месяца назад

    But Rick if have mutiple replacement like say 100 then I wouldn't perfer writing if else..can we use switch or any better way..

  • @raphaellebeau6368
    @raphaellebeau6368 2 года назад +1

    like + sub, to the point and well explained!

    • @BIGorilla
      @BIGorilla  Год назад

      The benefits to this method are numerous. Happy it clicked!

  • @JorgePerez-bu4ph
    @JorgePerez-bu4ph Год назад +2

    Hi mate! Very useful video. I'm relatively new to Power BI/Power Query. I need to complete some missing data on my table, more exactly missing city names on addresses. Your code worked perfectly when I need to change one name to another, but it doesn't work when the field/column is blank or null. Any idea why?

    • @Timbollew
      @Timbollew Год назад

      Try changing code at the end to Replacer.ReplaceText to Replacer.ReplaceValue or vice versa

  • @Gilligan2755
    @Gilligan2755 Месяц назад

    I keep having trouble making this work if the values I happen to be replacing are null. The condition I'm using is based on the value in another column, and it works just fine if do it by adding a conditional column. What am I doing wrong?

  • @jaapolsthoorn796
    @jaapolsthoorn796 2 года назад

    Hey Rick, does this break query folding or does it play nice? Any tips on extracting an hour from a date time stamp without breaking query folding? I couldn't work it out without turning the dts into a string, then using LEFT and RIGHT, which was very ugly...

    • @BIGorilla
      @BIGorilla  2 года назад

      Jaap!
      Unfortunately, no additional tips for that.
      Your approach works, extracting the time part with a Text.End( Text.From( [DateTime] ), 7 )... (I'm guessing somewhere around 7 characters).
      You could alternatively duplicate your DateTime column, and simply format it as Time as Data Type in the Power BI interface, don't do it in PQ.
      Ideally, create the column in your SQL database.
      Hopefully the engine supports Query Folding for Time data types in the future, however, for now it you'll have to find another way :(
      Cheers,
      Rick

  • @hiteshraja76
    @hiteshraja76 2 года назад +2

    Have a query : In Power query a column has text and dates both. I want to replace only the dates to null so that i can fill down the text. can you pls guide ?

    • @BIGorilla
      @BIGorilla  2 года назад

      Something like:
      if Value.Type( [Column] ) = "Text" then [Column] else null.
      Please have a good look what Value.Type returns for your text values. :)

  • @fachrulrizky
    @fachrulrizky 2 года назад +1

    Excellent video.. thank you so much!
    Could you tell me how to replace value when I have more than 1 condition (for example, I need to change the value for "India" under column Country on 17 December 2021 under Column "Date"
    Thanks in advance
    Best regards

    • @BIGorilla
      @BIGorilla  2 года назад

      You can extend the logic in the video. So add an if condition that says: if [country] = "India" and [Date] = #date(2021, 12, 17) then true else false
      Please have a look at if-statements if you have any trouble there: gorilla.bi/power-query/if-function-in-power-query/

  • @Griffindor21
    @Griffindor21 Год назад

    Great vide! But it does not work if the cell already has a null value

  • @kathybunch2439
    @kathybunch2439 2 года назад +1

    Great video - one question - What change would you make if you were interest in changing the value if [STATE] contained the letter "T" rather than [STATE] = "Tamaulipas" - I cannot quite seem to get it right when trying to use a Text.Contains statement

    • @BIGorilla
      @BIGorilla  2 года назад

      Hi Kathy, You can try something like:
      each if Text.Contains( [STATE], "T" ) then x else y
      Hope that helps!

    • @johnzurales8461
      @johnzurales8461 Год назад

      @@BIGorilla For this to work, the word state needs to be proper case "State" which is the way the field name is shown in the video. I also tested a second condition with the script below and it works.
      = Table.ReplaceValue(#"Sorted Rows",
      each [Smoking_Allowed],
      each if Text.Contains([State],"T") then "x" else
      if Text.Contains([State],"E") then "y"
      else [Smoking_Allowed],
      Replacer.ReplaceText,{"Smoking_Allowed"})
      Question: How do you deal with the lower case "t" which is not picked up in my example. I'd like it to test for upper or lower case letter T.
      Great video. I struggled for hours 😀with the text contains function until I found this comment.
      Thanks,
      John

    • @BIGorilla
      @BIGorilla  Год назад

      @@johnzurales8461 you can use the third optional argument of text . contains and fill in: Comparer.OrdinalIgnoreCase. This tests for your value case insensitive. Cheers 😁

  • @isaacmuhanga
    @isaacmuhanga Год назад

    Helpful. But what is the "No" is instead some column reference, will it work?

  • @Donzell1Dawson
    @Donzell1Dawson 2 года назад +1

    I like your solution! What about if a "contains" if formula? I will like to keep all values that contain Season (i.e. Season 1, Season 4, etc.) and delete everything else in my Season column. Total noob here.😁

    • @BIGorilla
      @BIGorilla  2 года назад

      try something like : if Text.Contains( [Season], "Season" ) then [Season] else null

  • @arukhush7024
    @arukhush7024 2 года назад

    Does this work for date columns? Didn't work for me

  • @akshaypatil8155
    @akshaypatil8155 Год назад

    One column contains values as 8806182550997, 1005RN07. I want to replace the alphabets in the second value with 00 1) What data type should i keep for the column? How do i do it ? I tried to keep data type of column as Text, Replace function in power query is not able to recognize the text part????

  • @nikhilashishitlive8582
    @nikhilashishitlive8582 2 года назад

    Sir can we change multiple thing without using formula

  • @sophykeo9639
    @sophykeo9639 7 месяцев назад

    how to display percentage of Valid , Error, Empty below header?

  • @felipesignorellireis7839
    @felipesignorellireis7839 2 года назад

    So, will the other States, other than Tamaulipa, continue with the original value? I notice that in the formula "if" the states different from Tamaulipa remain as "No" as original not changing to "Smoking Allowed"

    • @BIGorilla
      @BIGorilla  2 года назад +2

      Hey Felipe,
      You are correct. Lines where the state is different from Tamaulipas, keep their original value. The original value was in a column named "Smoking Allowed". The formula therefore returns the original value of that column. The words 'smoking allowed' are not returned.

    • @felipesignorellireis7839
      @felipesignorellireis7839 2 года назад

      @@BIGorilla Thank you!!

  • @gezin_longuevilleosaer4245
    @gezin_longuevilleosaer4245 Год назад +1

    Hi Rick, in my example it did not work when there was a null value in the column, after fixing that the magic was there 🙂

    • @lucaspatterson4033
      @lucaspatterson4033 Год назад

      Just ran into the same issue. Thanks for pointing this out. Inserted a step above to replace nulls with zeroes and it started working. Thanks!

  • @TehKonnos
    @TehKonnos Год назад +3

    Note, that if you want to replace NULL values, you have to check the checkbox "Match entire cell contents"

    • @Timbollew
      @Timbollew Год назад +4

      For so long this has bothered me why this wouldn't play nice with null values but you are correct this resolves it! Thank you. It seems if you are having an issue with nulls (might extend to other data types also) change Replacer.ReplaceText to Replacer.ReplaceValue or vice versa.

    • @BIGorilla
      @BIGorilla  Год назад +2

      You're right. null is not considered a text value, so Replacer.ReplaceValue is required. I explained some of that here:
      gorilla.bi/power-query/replace-values/#replacer-functions

  • @nickvanmaele8059
    @nickvanmaele8059 Год назад

    This trick is great but it does not seem to work with columns of type logical. Change the type to text first, then replace, then switch back.

  • @williamrhopkins
    @williamrhopkins 2 года назад

    Hi is there anyway to make the column name in the each clause a variable? In you example I wish to do something like myColumntoUpdare = {Smoking Allowed} and then ...each myColumnToUpdate...I have use cases where I don't know the column to update in advance and would like this to be dynamic

    • @BIGorilla
      @BIGorilla  2 года назад

      Good question, I'm not sure at this point...

    • @sergeiStPetebaklan
      @sergeiStPetebaklan 2 года назад

      As variant
      listOfColumns = {"Smoking_Allowed"}, // could be few
      #"Replaced Value" = Table.ReplaceValue(#"Changed Type",
      "Tamaulipas", //a
      each [State], //b
      (c, a, b) => if a = b then "No" else c,
      listOfColumns ) //c

  • @ANDRENASUUKYI
    @ANDRENASUUKYI 2 года назад

    Hi, I need replace values on incremental value. E/g week 22 as week 1, week 23 as week 2 & so on. How to I perform the action in Powerbi

    • @BIGorilla
      @BIGorilla  2 года назад

      You can try something like:
      if [weeknumber] >= 22 then [weeknumber] - 22 else [weeknumber] + 33
      I'm not fully sure the +33 is correct, but some number should work there. Hope it helps!

    • @ANDRENASUUKYI
      @ANDRENASUUKYI 2 года назад

      @@BIGorilla it worked thanks ! "Week " & if >= 22 , -21)

  • @rakeshsahoo16
    @rakeshsahoo16 Год назад

    any idea ,,some logic for SQL?

  • @lorenlim2315
    @lorenlim2315 5 месяцев назад

    what if im replacing a date column?

  • @alexlijesen6197
    @alexlijesen6197 2 года назад +1

    Thanks for your clear explanation but I would like to go a little deeper.
    The following: Can you also change value in the cell with a step
    e.g. search for “->” and change that to “|” with an if function
    Old current cell value = “explanation ->”
    New value in cell = "explanation |"

    • @BIGorilla
      @BIGorilla  2 года назад +1

      hi Alex,
      From what you describe you can do that with the regular replace operation. No need for a conditional replacement. Just right click the column, replace values, and replace "->" by "|"

  • @ExcelInstructor
    @ExcelInstructor 2 года назад

    Hello :)
    I do have a question.
    Honestly - i found this solution somewhere else.
    that said I also have an problem. when I operate on text values like you, it works perfectly.
    But when in my equivalent of [State] column I do have an object like Table or List and I do a check if the Object is empty List.Isempty or Table.IsEmpty it stops working correctly and return the value that was originaly in this column.
    why is that?
    Can you help out?

    • @BIGorilla
      @BIGorilla  2 года назад

      I'm afraid I don't understand the question.

    • @ExcelInstructor
      @ExcelInstructor 2 года назад

      @@BIGorilla ok Let me try asking this way.
      Imagine that instead of classical text / Value in [State] you do have and object nested Like another Table or List.
      Now can I using Replace.Values function to change Table / List object into null value when Table or List is empty?

  • @srikantmukherjee1034
    @srikantmukherjee1034 2 года назад +1

    Can we Replace any Text Before a Delimiter in Power Query?
    Like I have below Excel
    Zone - MP
    Region - Veg
    Nepal
    State-Bhtan
    Dubai
    In ExcelSheet, Find and Replace, We do like * - and Replace All
    What to be Used in Power Query to Replace any Text or Value Like *
    Please Help

  • @KlausEltrop
    @KlausEltrop 5 месяцев назад +1

    I would like to give hundreds of "thumbs up" 👍🙂 but sorry ... there is only one 😞

  • @JonathanExcels
    @JonathanExcels 2 года назад +1

    When is the ‘each’ statement required in a formula.

    • @BIGorilla
      @BIGorilla  2 года назад +2

      Hey Jonathan,
      The each expression has been put into place to make it easy to define simple functions. You could write a simple expression that needs a number as input and increments it by 1:
      (Y) => Y + 1
      You can write this the same by:
      (_) => _ + 1
      Microsoft created a shortcut to get here by using:
      each _ + 1
      So in the example I show, a good formulation would be:
      (_) => if _[State] = "Taumaulipas" then "No" else [Smoking_Allowed].
      Each makes the expressions more readable. It's good to know its a shortcut for the regular function.
      We need the function in the replace argument, since we don't replace values by a single other value. We want to apply logic, and therefore need the function.

  • @workstuff5253
    @workstuff5253 2 года назад +1

    I have used this method before but came across a problem when my field name had a "/" or "\". It doesn't recognise the square bracket notation to reference the field name and using the underscore shorthand for "this column" didn't work either. Renaming the field with a space instead of the "/" fixed the issue.
    PS: Nice "Buddy Christ" (Dogma) on your shelf behind 👍

  • @hectordelvillar1246
    @hectordelvillar1246 Год назад

    Hi Rick, this trick seems to be really good but for some reason, it does not work for me. I carefully followed every step but my "Hospital Group" column keeps returning null values. Even after checking the "Match entire cell context" box. Any help? Here is my formula
    each [Hospital Group],
    each if [MAK Code] = "510115" then "Huron Perth Alliance - Stratford General Hospital Site Hospital Reporting Cluster"
    else [Hospital Group],
    Replacer.ReplaceText,{"Hospital Group"})

    • @BIGorilla
      @BIGorilla  Год назад

      Hey Hector, Sorry to hear that.
      Could you change your code from: Replacer.ReplaceText, to Replace.ReplaceValue? Give that a try. I've explained their uses here: gorilla.bi/power-query/replace-values/#replacer-functions

    • @hectordelvillar1246
      @hectordelvillar1246 Год назад

      @@BIGorilla Hi Rick, thanks for the help and your quick answer. Not sure why is not working on my end. I have tried both methods (ReplaceText and ReplaceValue) but my Hospital Group column is still showing null for those values.

    • @BIGorilla
      @BIGorilla  Год назад

      @@hectordelvillar1246 It's hard to troubleshoot with you without seeing an example. Maybe you could:
      - Look on my site on the URL provided above to see working examples
      - Test the data type of your column (perhaps null values are causing issues?)
      - Provide a test query that shows the issue.

    • @hectordelvillar1246
      @hectordelvillar1246 Год назад

      @@BIGorilla Hi Rick, not sure if you received my email but I sent you the details that show the issue (July 3rd). I hope I can hear back from you. Again, thank you for all the help!

  • @isabellarocks1000
    @isabellarocks1000 Год назад

    I want to add a today function in this. I need if [state] = greater than today then "Completed" else "_". Can anyone help me with the code for this?

    • @BIGorilla
      @BIGorilla  Год назад +1

      Today in power query you can make Wkth:
      Date.From( DateTime.LocalNow() )
      Make sure the comparison column is of Date type 😁

    • @isabellarocks1000
      @isabellarocks1000 Год назад

      @@BIGorilla I really appreciate the response. I typed =if [State] < = Date.From(DateTime.LocalNow() ) Then "Yes" Else "_" it put error in every box. Where do I put the < symbol

    • @BIGorilla
      @BIGorilla  Год назад

      @@isabellarocks1000
      =if [State]

    • @isabellarocks1000
      @isabellarocks1000 Год назад

      @@BIGorilla I had a space between

    • @isabellarocks1000
      @isabellarocks1000 Год назад

      @@BIGorilla would it be possible to add 30 days from today?

  • @edgarsan71991
    @edgarsan71991 2 года назад

    00:29 You almost pronounce correctly jaja, are you using XML from Mexico to retrieve all this dataset?

  • @gettokeroro5007
    @gettokeroro5007 Год назад

    I try to use each if Text.startwith or Text.Endwith to replace with condition but it not working

  • @Faisal63045
    @Faisal63045 2 года назад

    Thank you for sharing
    When I try replace text valu nothing happen when I investigate it I found the original value show as below
    Donald#(00A0)Duke