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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
JulietZhu
Helper IV
Helper IV

Show last 13 months based on user single slicer selection

I am working on month end report. The whole report is using last month as slicer. But also need show last 13 months trending file.

 

I find 1 online example (https://1drv.ms/u/s!AlYpYKwSuOKxhEcVysiK6Mh6XFz_) showing exact what I am looking for.

Capture.PNG

 

 

But with my data, after following all the steps from above online example, I can’t get the above visualization. Not sure why. Please help. Thanks.    https://1drv.ms/u/s!AlYpYKwSuOKxhEiZlxoSfSclawpb  (from my data)

Capture2.PNG

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @JulietZhu,

 

The first variable of your Payment Last N is incorrect you are refering to the Payment_Amt however you want to calculate the Maximum date so you should refer to DateFilter column:

 

 

 

 

Payment (last n months) = 
VAR MaxFactDate =
    CALCULATE ( MAX ( DataFromDB[DateFilter]); ALL ( 'Date' ) ) 
VAR FDate =
    ENDOFMONTH ( 'Date'[Date] ) 
VAR Edate =
    EDATE ( FDate; -[N Value] ) 
RETURN
    IF (
MaxFactDate <= MAX ( 'Date'[Date])
&& MaxFactDate > Edate;
        CALCULATE ( SUM ( DataFromDB[Payment_Amt_Abs] ); ALL ( 'Date'  ) )
    )

 

Check below the result:

 

rolling.gif

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @JulietZhu,

 

The first variable of your Payment Last N is incorrect you are refering to the Payment_Amt however you want to calculate the Maximum date so you should refer to DateFilter column:

 

 

 

 

Payment (last n months) = 
VAR MaxFactDate =
    CALCULATE ( MAX ( DataFromDB[DateFilter]); ALL ( 'Date' ) ) 
VAR FDate =
    ENDOFMONTH ( 'Date'[Date] ) 
VAR Edate =
    EDATE ( FDate; -[N Value] ) 
RETURN
    IF (
MaxFactDate <= MAX ( 'Date'[Date])
&& MaxFactDate > Edate;
        CALCULATE ( SUM ( DataFromDB[Payment_Amt_Abs] ); ALL ( 'Date'  ) )
    )

 

Check below the result:

 

rolling.gif

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix, you are absolute right. I took me 3 days to figure it out. Now you only took minutes. Thanks so so much.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors