Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Previous Date Value Calculation is not working as expected - Immediate response required

Hello There, We have a Sales Table where the sales date values are stored twice in a month in the format of 2024-06-01, 2024-06-15 for each months.   Now I need to derive a measure to compare the ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi lbendlin I can see the expected result now.  One of the field used along with this measure in the table was not aggregated like SUM (netamt). Don't Summarize was used for this column. So it was not returning the expected result. now my existing logic itself working as expected. Thanks for your inputs and suggestions on this lbendlin 

     

    %of CurrentSales vs Previous Sales = Var CurrentDate=MAX( 'Sales'[ SalesDate])

    Var PreviousDate = CALCULATE(MAX( 'Sales'[ SalesDate]),Filter(all('Sales'), 'Sales'[ SalesDate] < CurrentDate))

     

    Var PreviousSAles=  CALCULATE(sumx('Sales', Sales[ SalesAmount]), 'Sales'[ SalesDate]=PreviousDate)

     

    Var CurrentSales = SUM(Sales[ SalesAmount])
     

    Var Result =IF (PreviousSAles =0,0,ABS(CurrentSales - PreviousSAles) / PreviousSAles)

    Return  IF(Result = 0, "0.00%", FORMAT(Result , "0.00000") & "%")