Power Query - COALESCE Operator (Shorten those formulas with a cool "mystery" operator)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 เม.ย. 2024
  • Learn how to write more efficient formulas using the COALESCE operator when dealing with NULLs in the source data. This is a great way to shorten If...Then...Else statements as well as Try...Otherwise statements.
    File Download Link:
    www.bcti.com//wp-content/YT_D...
    00:49 File Download Instructions
    00:58 Problems when working with NULLs
    02:22 Detecting and Replacing Missing Data
    06:18 Using COALESCE to Replace IF...THEN...ELSE Statements
    09:37 Conclusion
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 43

  • @patrickangwin810
    @patrickangwin810 24 วันที่ผ่านมา +14

    This is GREAT. I don't know how long your channel has been going; I have been watching Excel tutorials for many years and only recently come across you, but BCTI is fast becoming one of my favourite resources. Not only because your teaching style is so well paced, clear and easy to follow but, more importantly, because you often cover and introduce me to really useful, practical techniques I haven't seen elsewhere.
    Really good work, keep it up!

    • @bcti-bcti
      @bcti-bcti  24 วันที่ผ่านมา +5

      WOW!!! You've made my day. Such high praise. We just had our 1-year anniversary a few weeks ago, so we are still in our infancy. We hope to grow big and strong like the other channels. With your help, we'll get there. Thanks for watching.

  • @Undistinguished-ux9eg
    @Undistinguished-ux9eg 17 วันที่ผ่านมา

    Amazing explanation of this little-known Power Query operator. I have already used it at work today, shortening my rather longer If formula.
    My use case: My imported bank account data has the debits and credits in separate columns (both being positive figures). I like them combined into 1 column. So instead of saying “If” debit column has a figure then give me that figure, “Else” give me the credit figure multiplied by minus 1, I just say: [Debit] ?? -[Credit].
    Aside of being shorter and more efficient - it just make me feel so much cooler and gives me some unexplainable satisfaction.
    Thank you sir, and adding to my other comment today, you’re now the GOAT of Power Query too:)

  • @baskis69
    @baskis69 22 วันที่ผ่านมา

    I was completely unaware of this operator. Very useful. You always deal with issues that help us in our day to day! Thank you very much for sharing.

    • @bcti-bcti
      @bcti-bcti  22 วันที่ผ่านมา +1

      My pleasure. Thanks for watching.

  • @RichardJones73
    @RichardJones73 24 วันที่ผ่านมา +5

    The number of times I created another column for null values to become 0, is replaced value null with 0, when I didn't need to! Awesome tip

    • @bcti-bcti
      @bcti-bcti  24 วันที่ผ่านมา +1

      Yeah, I used to do the very same thing. Now my queries have fewer steps. I love being able to get to the objective with less work. Thanks for watching.

  • @Donkeys_Dad_Adam
    @Donkeys_Dad_Adam 24 วันที่ผ่านมา +5

    this is EPIC.

    • @bcti-bcti
      @bcti-bcti  24 วันที่ผ่านมา

      Thanks! I think so, too.

  • @ES-IvanCortinas
    @ES-IvanCortinas 20 วันที่ผ่านมา

    Excellent explanation. Thank you!!

  • @sharmarudra
    @sharmarudra 23 วันที่ผ่านมา

    Worth in Gold. Thank you.

    • @bcti-bcti
      @bcti-bcti  22 วันที่ผ่านมา

      You are very welcome! Thanks for watching.

  • @suvojitghoshal1453
    @suvojitghoshal1453 22 วันที่ผ่านมา

    Truly Truly Awesome content. Just Brilliant. !!

  • @user-dn5gd1rn9f
    @user-dn5gd1rn9f 22 วันที่ผ่านมา

    This is great!!! I really struggle with blank date fields. Can’t wait to try this!

    • @bcti-bcti
      @bcti-bcti  22 วันที่ผ่านมา

      So glad to hear that may help. Thanks for watching.

  • @leewism
    @leewism 23 วันที่ผ่านมา

    Never saw this option before, love it. I think I will be using it a lot.

    • @bcti-bcti
      @bcti-bcti  23 วันที่ผ่านมา

      Same here. I find it quite useful. Thanks for watching.

  • @djl8710
    @djl8710 24 วันที่ผ่านมา +1

    Cool thanks!

    • @bcti-bcti
      @bcti-bcti  24 วันที่ผ่านมา

      You are most welcome. Thanks for watching.

  • @jerrydellasala7643
    @jerrydellasala7643 23 วันที่ผ่านมา +1

    After retiring in June 2020, I learned about Power Query, and have watched well over a thousand PQ videos. This is the first time I heard of the Coalesce operator! Nice!!

    • @bcti-bcti
      @bcti-bcti  23 วันที่ผ่านมา +1

      Yeah, it’s something I had never seen or heard until just a few months ago. I’m not sure why this is such an overlooked feature. Thanks for watching.

  • @jazzista1967
    @jazzista1967 9 วันที่ผ่านมา +1

    Very elegant trick with the ?? 0 if null technique. When i deal with scenarios like those, I would usually replace the null with zeros by using the find and replace user interface that way, PQ will perform the operation i need ( Lets say add or subtract). Just subscribe to your channel .Thanks

    • @bcti-bcti
      @bcti-bcti  9 วันที่ผ่านมา

      Thanks for your time and for subscribing!

  • @larmondoflairallen4705
    @larmondoflairallen4705 23 วันที่ผ่านมา

    Gadzooks! I wish I had known about this capability years ago, but I am going to wear this out now.

    • @bcti-bcti
      @bcti-bcti  23 วันที่ผ่านมา

      AWESOME!!! Wear it out, my man.

  • @Giridharan952
    @Giridharan952 23 วันที่ผ่านมา

    wow .... great time saving ..sir,really useful for m code learners and also high practical use applicability

    • @bcti-bcti
      @bcti-bcti  23 วันที่ผ่านมา

      I couldn't agree more!

  • @serdip
    @serdip 24 วันที่ผ่านมา +1

    This was AMAZING!! Thank you so much for demonstrating this very powerful M Code technique, which greatly simplifies formulas in many common scenarios. I thought COALESCE() was just a function in T-SQL. :-)
    I wanted to try and make the summation of the Interantional and Domestic Sales table dynamic, meaning that if for some reason the source dataset was updated with another column, e.g. [Local Sales] (I couldn't think of a good name, LOL) or perhaps the source column names were changed. I noticed that the solution you provided, since it has hard coded column names, will not update to reflect values in the new [Local Sales] column or if the names of the columns changed.
    My solution was to convert each row of the table to a Record (actually each row *is* a record but in my thought process I had to "convert" it explicitly to a Record object), convert that Record to a List, select on the numeric values in the list and finally apply List.Sum() to the result. My solution is not very appealing visually, but it does handle the new [Local Sales] column automatically. It also works if any of the numeric columns in the source data gets renamed.
    So, at least in some limited cases, my solution might be helpful.
    Dynamic Summation - Column Names Not Hard Coded
    = Table.AddColumn(#"Removed Columns", "Sum Numeric Columns", each List.Sum(
    List.Select(
    Record.ToList(_),
    each Value.Is(_, Number.Type)
    )
    )
    )
    Again, this video (and all the rest of your content, quite frankly) is incredible! 😎
    Thank you kindly.

    • @bcti-bcti
      @bcti-bcti  24 วันที่ผ่านมา +3

      Thank you so much for taking the time to contribute to the channel. I think it's great that you are taking the idea to a whole other level. I'm sure other readers will appreciate your contribution. It's always a good idea to try to make things dynamic if possible.👍👍

  • @thelastfry23
    @thelastfry23 23 วันที่ผ่านมา +1

    Fantastic video! I didn't even know PQ behaved like that on additions, makes complete sense now why sometimes I run into issues. Will definitely put this to good use in the future! Keep up the excellent videos!

    • @bcti-bcti
      @bcti-bcti  23 วันที่ผ่านมา +1

      Glad to have helped!

  • @Jill_Liu
    @Jill_Liu 23 วันที่ผ่านมา +1

    Such an amazing tricks. I have been following your channel for a while i noticed that your tutorials are quite advanced explaining in a simple way. Great thanks for your sharing.

    • @bcti-bcti
      @bcti-bcti  23 วันที่ผ่านมา +1

      Thank you so much for taking the time to watch. I appreciate your thoughts. Very nice comment.

  • @hichamhadj9640
    @hichamhadj9640 12 วันที่ผ่านมา

    Your videos are amazing 😭

    • @bcti-bcti
      @bcti-bcti  12 วันที่ผ่านมา +1

      Thank you. That’s a very complementary thing to say. Thanks for watching.

  • @txreal2
    @txreal2 24 วันที่ผ่านมา

    Thanks 😊

  • @RonDavidowicz
    @RonDavidowicz 24 วันที่ผ่านมา +1

    I haven’t used this before, unfortunately I probably won’t know what I was doing if I looked at it later!😊

    • @bcti-bcti
      @bcti-bcti  24 วันที่ผ่านมา +1

      I suffer from that syndrome as well. If I don't use it often enough, I'll just end up confusing myself later. But I think this is cool enough to try working into my day-to-day operations. Thanks for watching.

  • @ManthaarJanyaro
    @ManthaarJanyaro 24 วันที่ผ่านมา

    That's good 👍🏻😊

  • @williamarthur4801
    @williamarthur4801 23 วันที่ผ่านมา

    New to the channel, will subscribe,

    • @bcti-bcti
      @bcti-bcti  23 วันที่ผ่านมา

      Thank you 👍🏻👍🏻👍🏻

  • @lesterpotts6142
    @lesterpotts6142 24 วันที่ผ่านมา

    Thank you, much appreciated.
    You can add Cole Lesch now to your list of sales reps.

    • @bcti-bcti
      @bcti-bcti  24 วันที่ผ่านมา

      You are SOOOO right! That's a good one!