Power Query Secrets: Use coalesce (??) to handle null values

Поділитися
Вставка
  • Опубліковано 17 лис 2024

КОМЕНТАРІ • 39

  • @ExcelOffTheGrid
    @ExcelOffTheGrid  Місяць тому

    Sign up for our free Insiders program and get the example file:
    exceloffthegrid.com/insiders-signup/
    File Reference for this video: 0228 Coalesce in Power Query

  • @zingmo
    @zingmo 2 місяці тому +7

    This is a great way to have values in one column override the values in another if they are present without having to create a conditional column.

  • @timtunbridge
    @timtunbridge Місяць тому +1

    Example 3 is genius over tested ifs. Love it Mark.

  • @williamelliott5999
    @williamelliott5999 2 місяці тому +2

    In your trial balance example, the "each [Debit] ?? 0 - [Credit] ?? 0" only seems works when one column or the other is, in fact, null. If there is a risk that there are numbers in each column, the this formula only returns the first column.
    A safer variant would be to surround the elements with brackets "each ([Debit] ?? 0) - ([Credit] ?? 0" ) .
    My favoured route is to use List.Sum which acts like Sum in Excel so is quite forgiving (if that's what you want) and i would write "each ListSum({[Debit],[Credit]})" This has the flexibility to work across adding several columns with some safety!

    • @ExcelOffTheGrid
      @ExcelOffTheGrid  2 місяці тому +1

      Good point about the calculation precedence. With my data it would be impossible to have a debit and a credit at the same line, so it will work.
      Good use of brackets and List.Sum to avoid it. 👍

    • @DaveIsAtWork-Really
      @DaveIsAtWork-Really Місяць тому

      @@ExcelOffTheGrid Normally it is not possible to have both a Debit and a Credit balance for an account, but I sometimes work with multiple divisions or companies listed side by side, giving something like Co1.Dr, Co1.Cr, Co2.Dr, Co2.Cr ..... = Grand Total Account Balance. Enclosing each element with () would get to the right total.

  • @mohammedelsakally540
    @mohammedelsakally540 2 місяці тому +1

    Thank you Mark for the valuable content you are providing to your followers 👍 🙏

  • @michaelbrown8821
    @michaelbrown8821 Місяць тому

    OK, i subscribed. I coalesced. Thx for this great feature.

  • @extraktAI
    @extraktAI Місяць тому +1

    Great video, thanks!

  • @zzota
    @zzota 2 місяці тому +1

    Great trick. Thanks, Mark.

  • @stefankirst3234
    @stefankirst3234 2 місяці тому +1

    That´s a really, really useful concept 😃 Never even heard of it before 🤯 Thank´s a bunch!

    • @ExcelOffTheGrid
      @ExcelOffTheGrid  Місяць тому

      It’s a niche piece of underground knowledge - I hope you can put it to good use.

  • @ziggle314
    @ziggle314 Місяць тому

    Thanks Mark. Great job.

  • @ramruttunaubeeluck9235
    @ramruttunaubeeluck9235 2 місяці тому +1

    Thank you Mark

  • @rpopecpa
    @rpopecpa Місяць тому +1

    Hi Mark, I love your videos. I just ran into a scenario where I was filtering out rows with data that contained specific text. In my case, it was the word "DEPOSIT". So I created a filter that said 'each not Text.Contains([Description], "DEPOSIT")'. This did not work as my [Description] column contained nulls that I wanted to keep. Therefore, I added the Coalesce formula. 'each not Text.Contains([Description] ?? "", "DEPOSIT")' Now, the formula works as intended. Thanks!!

  • @pratiklpatel
    @pratiklpatel 2 місяці тому +1

    I already subscribed, this would have saved one more record being null :)
    Great video by the way.

  • @GrainneDuggan_Excel
    @GrainneDuggan_Excel Місяць тому

    Intriguing examples. Thanks Mark

  • @Ratnakumarwrites
    @Ratnakumarwrites 2 місяці тому +1

    Great learning... Thanks 😀

  • @mirrrvelll5164
    @mirrrvelll5164 Місяць тому

    This was a neat one. ☝️ I find it useful

  • @raimundojs9547
    @raimundojs9547 Місяць тому

    Perfect! Thank you!

  • @Trucpq
    @Trucpq Місяць тому

    Another good practice. Thanks

  • @yousrymaarouf2931
    @yousrymaarouf2931 Місяць тому

    amazing

  • @gonzuic
    @gonzuic Місяць тому

    Great information, really great.
    Thanks

  • @sagunmaghaia4831
    @sagunmaghaia4831 2 місяці тому +1

    Awesome

  • @kebincui
    @kebincui 2 місяці тому +1

    👍❤

  • @darrengraham27
    @darrengraham27 26 днів тому +1

    Awesome