Forum Discussion
Add values at missing dates
- 6 years ago
I had a quick look at the file. There are relationships. If you delete them or make them inactive i believe it works (the resulting table has then around 7 million rows)
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers

Try creating a new table (Table2 is the second one you show):
TableRes =
GENERATE (
Table2;
GENERATESERIES (
CALCULATE ( DISTINCT ( Table2[Date] ) );
VAR Current_ =
CALCULATE ( DISTINCT ( Table2[Date] ) )
VAR Next_ =
CALCULATE (
MIN ( Table2[Date] );
Table2[Date] > Current_;
ALL ( Table2[StockQty] )
)
RETURN
IF ( NOT ISBLANK ( Next_ ); Next_ - 1; Current_ )
)
)
You'll have the actual date column in "Value". Delete the column 'Date' and rename Value as Date. All this would probably be more elegant in M.
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers ![]()
AlB
For personal enrichment, could you clarify how this piece of code is working? In the sample file that you share the above code works as intended, but when I tried to incorporate it into my own PBI, sometimes it's not generating a date
e.g. in the table below - for unclear reasons - 2023-04-26 was not generated
| Date | Present in original table | Generated by your code |
| 2023-04-18 | True | True |
| 2023-04-19 | True | True |
| 2023-04-20 | False | True |
| 2023-04-21 | False | True |
| 2023-04-22 | True | True |
| 2023-04-23 | True | True |
| 2023-04-24 | True | True |
| 2023-04-25 | True | True |
| 2023-04-26 | False | False |
| 2023-04-27 | True | True |
| 2023-04-28 | True | True |
| 2023-04-29 | True | True |