Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

DAX Measure - Get Prior Amount

hello all - i have a table that shows customer order information - Order Id, Customer Id, Order Date, Status, Amount. If i select a time period - month, quarter, etc. i need to show the the last period Amount. For example, if i select 2019 March, i want to show the Order Amount where the order date = March 1st 2019. Any ideas?

3 Replies

  • Hi Anonymous,

     

    You can calculate the First day of the month using below DAX formula:

    FirstdayofMonthSales = CALCULATE(sum(Data[Sales]),STARTOFMONTH(Data[Date]))
     
    Please accept my answer as a solution if Its helped you!!!
     
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    I assume you are wanting to do a Date Filter. There are multiple Types in this, You could use a Drop down Date Filter or a Slicer to Specify the Date Range ( Start and End Date).

    1. Single Date Value

    Value := 
    VAR Date= SELECTEDVALUE(Order[date])
    RETURN CALCULATE(SUM(Order[Order], Order[date]= Date)

    2. Date Range (Slicer)

    Value:= VAR First_Date= FIRSTDATE(Order[date])
    VAR Last_Date=LASTDATE(Order[date])
    RETURN CALCULATE(SUM(Order[Orders]), FILTER(Order, Order[Date] >= First_Date && Order[Date]<= Last_Date))

    Best Regards,
    Vignesh M

    If what I suggested worked for you feel free to Drop a "Kudos" and Consider to "Accept as Solution" if I solved your Issue :)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous wrote:

      Hi,

       

      I assume you are wanting to do a Date Filter. There are multiple Types in this, You could use a Drop down Date Filter or a Slicer to Specify the Date Range ( Start and End Date).

      1. Single Date Value

      Value := 
      VAR Date= SELECTEDVALUE(Order[date])
      RETURN CALCULATE(SUM(Order[Order], Order[date]= Date)

      2. Date Range (Slicer)

      Value:= VAR First_Date= FIRSTDATE(Order[date])
      VAR Last_Date=LASTDATE(Order[date])
      RETURN CALCULATE(SUM(Order[Orders]), FILTER(Order, Order[Date] >= First_Date && Order[Date]<= Last_Date))

       


      I just did a test but it is returning the same value as the Amount. See below. For example, for customer 456, date 4/1/2019, the Value measure should be 50. Thoughts?