Forum Discussion

JoakimHGjerde's avatar
JoakimHGjerde
Copper Contributor
Nov 27, 2020
Solved

PQ / Data Model - Turning non consecutive days into consecutive with the value from previous day

Hi, I have a very particular use case, where I have a data set with account balances and a data set with all calendar dates for a period. The account balances however may only contain some of the da...
  • SergeiBaklan's avatar
    Nov 27, 2020

    JoakimHGjerde 

    Better if you provide sample file instead of screenshot, but let try this way. I'd suggest Power Query

    - yes, you need Date table, but don't generate in Excel sheet, you may find a lot of samples how to do such table by Power Query

    - if second table is Source, reference on it, keep only Accounts column, remove duplicates, add custom column with =Date table, expand it on dates

    - Merge (left join) this table with Source on Account and Date, expand Balance

    - fix the table in memory by adding Index column and Group By on Accounts without aggregation

    - in formula bar change each _ on each Table.FillDown(_,{"Balance"})

    - expand column with grouped result

     

    Now you may load query to data model and create PivotTable from it; or pivot query and return table to sheet, etc.

Resources