Forum Discussion

Ibrahim_shaik's avatar
1 year ago
Solved

Dynamic Table Visual - Same date last Year

Hi Power BI Community,   I have a table in which i have date, time, temperature, humdity and power column is in another table and I want to create a table visual where the user selects the date fro...
  • MohamedFowzan1's avatar
    MohamedFowzan1
    1 year ago

    Hi Ibrahim_shaik 

    Have a last year column in the Main Table using the Date column that you have:
    LY Date= DATEADD('MainTable'[Date], -1, YEAR)

    We can achieve the previous year value using LOOKUP:

    Temperature_LY =
    LOOKUPVALUE(
        'MainTable'[Temperature],
        'MainTable'[Date], 'MainTable'[LastYearDate],
        'MainTable'[Time], 'MainTable'[Time]
    )

    Do the same for Humidity and since Power is from another table:

    Power_LY =
    LOOKUPVALUE(
        'PowerTable'[Power],
        'PowerTable'[Date], 'MainTable'[LastYearDate],
        'PowerTable'[Time], 'MainTable'[Time]
    )