Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum of last 12 months counting selected month

Hello,
First, I begin by thanking you for your answers and support for all those who are passionate about Power BI.

Please, as it is indicated in this two attached files below, I would like to display the sum of last 12 months, ie when I tick in my report the month of May 2018, I would like to calculate the average from last 12 months counting from May (ie from June 2017 -> May 2018).

But as you look in the attached files below, for the normal sum formula and the sum of last 12 months always I had the same result !!!!! which is too weird
Look at these two attached files below.

Thank you a lot.

Cordially.

Figure1.PNGFigure2.PNG

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

To update your measure as below.

 

Consomation_Matiere12Mois2 = 
VAR md =
    MAX ( 'BI Date'[Date] )
VAR d =
    CALCULATE (
        MAX ( 'BI Date'[Date] ),
        FILTER ( ALL ( 'BI Date' ), DATEDIFF ( 'BI Date'[Date], md, MONTH ) = 12 )
    )
RETURN
    SUMX (
        FILTER ( ALL ( 'BI Date' ), 'BI Date'[Date] <= md && 'BI Date'[Date] >= d ),
        [ConsoMatiere]
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try to use filter in your second formula.

 

 

ConsoMatire = CALCULATE([MEASURE],FILTER(your table, your table[column]="xxxx"))

If it doesn't meet your requirement, kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hello,
I did not find a solution for this problem.
Here is the link of my .pbix file

https://drive.google.com/open?id=1rMVWw7OwXtokFvoKVOqKuey0Wx-nPJ8g


I thank you very much.

 

 

Hi @Anonymous ,

 

To update your measure as below.

 

Consomation_Matiere12Mois2 = 
VAR md =
    MAX ( 'BI Date'[Date] )
VAR d =
    CALCULATE (
        MAX ( 'BI Date'[Date] ),
        FILTER ( ALL ( 'BI Date' ), DATEDIFF ( 'BI Date'[Date], md, MONTH ) = 12 )
    )
RETURN
    SUMX (
        FILTER ( ALL ( 'BI Date' ), 'BI Date'[Date] <= md && 'BI Date'[Date] >= d ),
        [ConsoMatiere]
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hello,
I am stuck to solve this problem.
your solution it did not work
Please help me
Thank you.

Anonymous
Not applicable

Hello, 

I used this solution: what do you think?
Do these two requests give the correct result or not?
Here is my link:
https://drive.google.com/open?id=1UCVgCkz-ZELGeerI3IV0ezlsnc00InYL
Thank you.

1.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.