Forum Discussion

elenton's avatar
elenton
Helper II
7 years ago
Solved

Previous Days Orders

Hi
I want to get all orders from the previous day. 

However if i use now() - 1 it pulls the time in which dosent link on my date table.

If i format the date it ends up as a string whcih is incompatable with the date its trying to link with.

How do i go about doing this. Below is one example i was trying to use

_Daily Sales =

var CurrentDay = DATE(YEAR(NOW()), MONTH(NOW()) , DAY(NOW()) -1)


Return

calculate(
count('Sales'[OrderID]),
_Date[Date]=CurrentDay)



  • elenton seems lke you have date dimension in your model, if yes then update measure

     

    Prev day sales = 
    CALCULATE ( SUM( Table[Sales] ), 
    PREVIOUSDAY( Date[Date] ) 
    )

8 Replies

    • elenton's avatar
      elenton
      Helper II

      parry2k sorry i missed that bit.

      I think the issue may be that the date format i am trying to link on is YYYY-MM-DD which is different to the fomat that the variable is producing.

      When i try to format the variable the same it is then converted to a string so data type mismatch. So im not sure how to then convert it back into a date.

       

      Or is there something more obvious im missing?

      • parry2k's avatar
        parry2k
        Super User

        elenton what exact error your are getting? Date function you used for var should return a date.