Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Sum on a dynamic date range

Hello,

I would like to calculate the sum on a dynamic date range, for example:
For March 2019, the sum of material consumption must be:
= Sum of material consumption (April 2018 to March 2019)

Another example :
For September 2019, the sum of material consumption must be:
= Sum of material consumption (October 2018 to September 2019)

Please what is the DAX formula to meet this need?

Thank you.
Cordially.

  • Hello:

    Try the following formula:

    MAT cost:= calculate([Sum of material consumption],datesinperiod(calendar[date],lastdate(calendar[date]),-1,year))

    Good luck,

    José Luis

3 Replies

  • joseluis1969's avatar
    joseluis1969
    Frequent Visitor

    Hello:

    Try the following formula:

    MAT cost:= calculate([Sum of material consumption],datesinperiod(calendar[date],lastdate(calendar[date]),-1,year))

    Good luck,

    José Luis

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello,

      For this table in Power BI which consists of the fields (fields of the different tables), how to invert the rows in columns and the columns in rows?
      You will find attached a screenshot of my table on Power BI.

      I thank you in advance.
      Cordially.

    • Anonymous's avatar
      Anonymous
      Not applicable

      It worked perfectly for me. Thanks a lot!