Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
richard-powerbi
Post Patron
Post Patron

Add column with next date filtered by another dates table

Table1: ID, DateA

1, 2019-01-01
2, 2019-01-02
3, 2019-01-03
4, 2019-01-04
5, 2019-01-05
6, 2019-01-06

 Table 2 (non working days): DateB

2019-01-02
2019-01-05
2019-01-06

Table 1 (column added): ID, DateA, DateC

1, 2019-01-01, 2019-01-03
2, 2019-01-02, 2019-01-03
3, 2019-01-03, 2019-01-04
4, 2019-01-04, 2019-01-07
5, 2019-01-05, 2019-01-07
6, 2019-01-06, 2019-01-07

I want to add a column to Table 1 with Power Query.

The logical steps are:

  • Date after date 2019-01-01 in Table 1 is 2019-01-02.
  • Check if date 2019-01-02 is in Table 2.
  • If date 2019-01-02 is in Table 2 then check if 2019-01-03 is in Table 2.
  • Repeat until there is a 'date after' result which is not in Table 2.

Note: it is possible that the next date does not exist in Table 1, so I'm looking for the next date in general which does not exist in Table 2. That's why 2019-01-07 is a valid result.

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @richard-powerbi,

 

Please see the attached file with the solution, the file contains Table1 and Table2 as per your sample and Function "Next Day Function" that has been invoked in Table1

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



 

 

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @richard-powerbi,

 

Please see the attached file with the solution, the file contains Table1 and Table2 as per your sample and Function "Next Day Function" that has been invoked in Table1

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



 

 

Thank you @Mariusz, excellent solution.

 

You also got me interested in this:

 

= Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VcjJCQAgDATAVmTfCjk0YC0h/beh5Lcwr8mEYmKY6F2iH2omjM76nM77Nt3uO3SnL+gCVQ8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Date = _t])
  1. Is it possible you could help me understand this syntax and how I could replicate something like this?
  2. I tried to convert this back with a web converter using Base64, but I couldn't get the expected result. Why is that?
  3. Is it also a good solution for storing data 'inside' the pbix file? Let's say, would it be possible to import external text files with a query, combine them, compress and store them inside the pbix, and then use this data for further processing? Because I'm looking for a way to keep the data 'inside' when the original files are removed...

If you want I can make an extra topic for this so you get new kudo's and it can be marked as a solution. Perhaps a Mod can split up this topic?

Hi @richard-powerbi 

 

This code is generated internally by query editor when you use "Enter Data" functionality.

I have never look dipper into that topic so probably you are better off creating new topic.

All I can say, there is a limitation to how many rows/columns you can paste there.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors