Forum Discussion

mterry's avatar
mterry
Helper V
7 years ago
Solved

DAX for monthly data with missing values

I have output data for several locations spanning multiple years (a portion of the data is attached). Some locations have consistent output throughout the year, some will have a change at one point d...
  • v-lili6-msft's avatar
    7 years ago

    hi, mterry 

    Based on my research, you could try this way:

    Step1:

    Create a dim year month date table or you could just use this formula to create a new dim table

    Dim Date = 
    SELECTCOLUMNS (
        FILTER ( CALENDAR ( "2018-01-01", "2019-12-31" ), DAY ( [Date] ) = 1 ),
        "Year No", YEAR ( [Date] ),
        "Month No", MONTH ( [Date] ),
        "Year Month", YEAR ( [Date] ) * 100
            + MONTH ( [Date] )
    )

    Step2:

    Add month column for date column in your basic table

    Step3:

    Use this formula to create a new table

    Table = FILTER(GENERATE(Basic,'Dim Date'),Basic[Year]='Dim Date'[Year No])

    Step4:

    In the new table, create a real outout column

    Real Output = IF('Table'[Month]<='Table'[Month No],'Table'[Ending Output],'Table'[Beginning Output])

    Step5:

    Drag Year month column and real output column from the new table into a visual

    Result:

    Here is sample pbix file, please try it.

     

    Best Regards,

    Lin