Forum Discussion

ossama_ibrahim8's avatar
ossama_ibrahim8
Regular Visitor
4 years ago
Solved

subtract sales units from previous day

i had daily sales sent tom me in excel but mtd 

so i need to sustract day 2 from day 1 to get real day 2 

i need dax formula to subtact with date 

can you help

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi ossama_ibrahim8 ,

     

    Is this a matrix or a table of data sources?
    If it is a data source, it is best to unpivot the date in Power Query and turn the date into a separate column.

    Select the Item Code and Item name, click 'Unpivot Other Columns'.

    You could get a column of dates and a column of values.

    Now you could create the following measure to get the value from previous day.

    Previous Value = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),[Item Code]=MAX('Table'[Item Code])&&[Attribute]=MAX('Table'[Attribute])-1))

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ossama_ibrahim8 ,

     

    It's the Power Query Forum. M language is used in it. While dax is used in Power BI Desktop.

    And here's the blog teaches you how to get the value from previous row:

    Value from previous row – Power Query, M language – Trainings, consultancy, tutorials (exceltown.com)

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi ossama_ibrahim8 ,

       

      Is this a matrix or a table of data sources?
      If it is a data source, it is best to unpivot the date in Power Query and turn the date into a separate column.

      Select the Item Code and Item name, click 'Unpivot Other Columns'.

      You could get a column of dates and a column of values.

      Now you could create the following measure to get the value from previous day.

      Previous Value = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),[Item Code]=MAX('Table'[Item Code])&&[Attribute]=MAX('Table'[Attribute])-1))

       

       

       

      Best Regards,

      Stephen Tao

       

      If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

       

  • n=i need to subtract 3-7-2022 value with items sales from 2-7-2022 value and every day