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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Moving Annual Total in stacked area chart

I need help to calculate MAT (moving annual total) where the user can seletec a specific month in the "MMYYYY" filter slicer and then see the MAT in a stacked area chart.

E.g. if the user select "022020" in the filter slicer the graph should show data from feb 2019 to feb 2020. If the user select "122019" the graph should show data from dec 2018 to dec 2019.

I have calculated MAT by:

Sales MAT =

CALCULATE(

'Fact Sales'[Sales];

DATESINPERIOD('Dimension Date'[date];LASTDATE('Dimension Date'[date]);-1;YEAR)

)

 

This calculation works fine in a table. My issue is when I what to show the data in a graph. Because when the user for example select "022020" then the graph only shows data from feb 2020 and not for the past 12 months!

 

 

Below is a picture of the MAT calculation that works fine in the table but not in the graph.
Capture.PNG

 

 

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on my research, I think it is a normal phenomenon. I created data to reproduce your scenario.

Table:

 e1.png

Calendar:

 

Calendar = CALENDARAUTO()

 

 

There is a one-to-one relationship between two tables.

 

I got the same result with the measure you provided.

 

Sales MAT = 
CALCULATE(
    SUM('Table'[Sales]),
    DATESINPERIOD(
        'Calendar'[Date],
        LASTDATE('Calendar'[Date]),
        -1,YEAR
    )
)

 

 

When you select one date, the gragh will display the result for the corresponding date. If you want to display more dates, you need to multi-select dates.

e2.png

 

If I misunderstand your thoughts, please show me your sample data and expected result. Do mask sensitive data before uploading. Thanks

 

Best Regards

Allan

 

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

 

 

amitchandak
Super User
Super User

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.