Forum Discussion

rcyber's avatar
rcyber
Icon for Resolver I rankResolver I
8 years ago
Solved

Average Value for Last 3 Days

Hi All!

 

I'm trying to create measure that will contains average value of Price for previous 3 days.

I have done it in Excel, it is very simple formula.

How can I create a measure in Power BI Desktop for it?

 

Thanks in advance,

Alex.

  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi,

     

    Try the below formula;

    Measure = IF(COUNTROWS(DATESINPERIOD(Price[Date],LASTDATE(Price[Date]),-3,DAY))>2,CALCULATE(AVERAGE(Price[Price]),DATESINPERIOD(Price[Date],LASTDATE(Price[Date]),-3,DAY)))

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    Try the below formula;

    Measure = IF(COUNTROWS(DATESINPERIOD(Price[Date],LASTDATE(Price[Date]),-3,DAY))>2,CALCULATE(AVERAGE(Price[Price]),DATESINPERIOD(Price[Date],LASTDATE(Price[Date]),-3,DAY)))

    • Anonymous's avatar
      Anonymous
      Not applicable

      I created a table Price with fields Date & Price. Added the measure to get the last 3 days average

      Measure = IF(COUNTROWS(DATESINPERIOD(Price[Date],LASTDATE(Price[Date]),-3,DAY))>2,CALCULATE(AVERAGE(Price[Price]),DATESINPERIOD(Price[Date],LASTDATE(Price[Date]),-3,DAY)))

       

    • rcyber's avatar
      rcyber
      Icon for Resolver I rankResolver I

      It works fine!

      Thank you so much!

       

      Alex.