cancel
Showing results for
Did you mean:
Regular Visitor

## Populate collection with missing days/dates

Hello Everyone,

If I have a collection with some data:

```Date               x  y   z

01/09/2019  15 32 16

02/09/2019  15  0   12

05/09/2019   1   3    0

15/09/2019   0   1    0

25/09/2019   0   0    55```

How would you fill all the missing dates with 0  0 0 value to obtain something like :

```Date               x  y   z

01/09/2019  15 32 16

02/09/2019  15  0   12

03/09/2019   0   0    0

04/09/2019   0   0    0

05/09/2019   1   3    0

06/09/2019   0   0    0

....

15/09/2019   0   1    0

16/09/2019   0   0    0

....

25/09/2019   0   0    55

....

30/09/2019   0   0    0

```

Or would you do it another way?

The goal is to have a gallery with every day of the selected month, with data coming from another data source.

Cheers

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User II

Hi @HD

Considering you want to do this for current month, please use the expression:

ForAll(FirstN([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],DateDiff(Date(Year(Today()), Month(Today()), 1),Date(Year(Today()), Month(Today()) + 1, 1))),If(!(Text(Date(Year(Today()), Month(Today()), 1+Value),"[\$-en-US]dd/mm/yyyy") in testcol1.Date),Collect(testcol1,{Date:Text(Date(Year(Today()), Month(Today()), 1+Value),"[\$-en-US]dd/mm/yyyy"),A:0,B:0,C:0})))

This will update the existing collection with the 0 value for dates that does not exist. Here, testcol1 is the name of my collection.

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
2 REPLIES 2
Dual Super User II

Hi @HD

Considering you want to do this for current month, please use the expression:

ForAll(FirstN([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],DateDiff(Date(Year(Today()), Month(Today()), 1),Date(Year(Today()), Month(Today()) + 1, 1))),If(!(Text(Date(Year(Today()), Month(Today()), 1+Value),"[\$-en-US]dd/mm/yyyy") in testcol1.Date),Collect(testcol1,{Date:Text(Date(Year(Today()), Month(Today()), 1+Value),"[\$-en-US]dd/mm/yyyy"),A:0,B:0,C:0})))

This will update the existing collection with the 0 value for dates that does not exist. Here, testcol1 is the name of my collection.

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Regular Visitor

thanks! works like a charm

Announcements

#### Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

#### Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Top Kudoed Authors
Users online (2,809)