Forum Discussion

Bimo's avatar
Bimo
New Member
4 years ago
Solved

fillin gaps

Hello  I have data like    02/01/2021   3 15/02/2021   5 05/04/2021   6 and I would like then to fill in gaps in dates to show as per below    Thanks    02/01/2021   3 0...
  • negi007's avatar
    4 years ago

    Bimo so i have tried to solve your issue

    1. so this is your table data. i have named it facts table in my model

    2. You can create a table having all date values from first date till last date in your data table. i have named it calendar table in my model.

    below code will create table for you

    calendar = CALENDAR(FIRSTDATE(facts[date]),LASTDATE(facts[date]))
     
    3. then you add another column to your calendar table by looking up value from facts table against available dates
    value = LOOKUPVALUE(facts[value],facts[date],'calendar'[Date])
     
    4. then you create another column to fill blank places using below code
    Value2 =
    VAR CurrentVal = 'calendar'[value]
    VAR CurrentDate = 'calendar'[Date]
    VAR LastDateWithValue =
    CALCULATE (
    MAX ( 'calendar'[Date] ),
    FILTER (
    'calendar',
    'calendar'[value] <> BLANK ()
     
    && 'calendar'[Date] <= CurrentDate
    )
    )
    RETURN
    //LastDateWithValue
    CALCULATE (
    SUM('calendar'[value]) ,
    FILTER (
    'calendar',
    'calendar'[Date] = LastDateWithValue
    )
    )
     
    below is final output that you were looking for
     

     

    i have taken som inspiration from this post to solve your problem
     

    i am attaching pbix file as well for your reference.

     

    do let me know if it resolve your problem. thanks