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

Поделиться
HTML-код
  • Опубликовано: 14 ноя 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 Месяц назад +6

    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

    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  Месяц назад +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.

  • @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!!

  • @ramruttunaubeeluck9235
    @ramruttunaubeeluck9235 Месяц назад +1

    Thank you Mark

  • @extraktAI
    @extraktAI Месяц назад +1

    Great video, thanks!

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

    Thanks Mark. Great job.

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

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

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

    Perfect! Thank you!

  • @zzota
    @zzota Месяц назад +1

    Great trick. Thanks, Mark.

  • @mohammedelsakally540
    @mohammedelsakally540 Месяц назад +1

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

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

    Intriguing examples. Thanks Mark

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

    amazing

  • @Ratnakumarwrites
    @Ratnakumarwrites Месяц назад +1

    Great learning... Thanks 😀

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

    Another good practice. Thanks

  • @stefankirst3234
    @stefankirst3234 Месяц назад +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.

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

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

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

    Great information, really great.
    Thanks

  • @pratiklpatel
    @pratiklpatel Месяц назад +1

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

  • @sagunmaghaia4831
    @sagunmaghaia4831 Месяц назад +1

    Awesome

  • @kebincui
    @kebincui Месяц назад +1

    👍❤

  • @darrengraham27
    @darrengraham27 22 дня назад +1

    Awesome