Forum Discussion

newbie2181's avatar
newbie2181
New Member
5 years ago
Solved

Compare value with average value from last 4 same weekdays

Hello,   I have a set of data (columns: day, day_name, value, increase) that looks something like this:   08-Sep Tuesday 200 13% 09-Sep Wednesday 150 -6% 10-Sep Thursday 200 23%...
  • amitchandak's avatar
    5 years ago

    newbie2181 ,

    Try measures like these with a date table

     

    7 behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-7,DAy))
    14 behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-14,DAy))
    21 behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-21,DAy))

    diff =
    var _cnt = if(isblank([7 behind Sales]),0,1)+if(isblank([14 behind Sales]),0,1)+if(isblank([21 behind Sales]),0,1)
    var _last3 = ([7 behind Sales]+[14 behind Sales]+[21 behind Sales]) /_cnt
    return
    divide([sales] - (_last3 ),_last3)

     

    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
    https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions



    Appreciate your Kudos.