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! Request now

Reply
sue_mcc21
New Member

When a table has only Years visible I want to get the last 91 days for last Year

Hi

 

I have the dax to get 91 days for previous year but when I try to put this in a visual with only the years showing I can not achieve this. I need to get the data from the filter which would be 9-10-2023 and get the last 91 days from the 9-10-2022. Any help much appreciated.

This is the code I have for retrieving the data which works fine when all the dates are in the visual

 

Qty Last 91 Days LY = CALCULATE(SUM('Data Details'[ Qty]),
SAMEPERIODLASTYEAR(
  DATESBETWEEN('Calendar SP1'[Date],  
  FIRSTDATE(DATEADD('Calendar SP1'[Date],-91,DAY)),
LASTDATE('Calendar SP1'[Date])
)))
 
Below is a snapshot of the outcome that I would like to achieve if possible.
 
YearThis YearLast Year - Last 91 Days
202360000105000
2022136000 
Total196000105000
   
DateValue91 Day Total
9/10/20221000 
2/10/20222000 
25/09/20223000 
18/09/20224000 
11/09/20225000 
4/09/20226000 
28/08/20227000 
21/08/20228000 
14/08/20229000 
7/08/202210000 
31/07/202211000 
24/07/202212000 
17/07/202213000 
10/07/202214000105000
17/07/202215000 
24/07/202216000 
Total136000 
 
Thankyou
7 REPLIES 7
sue_mcc20
New Member

Hi

Great thank you for this, however when I put it into a visual with Years only I get only the month from last year, I need the total for 91 days = 13 weeks

Thanks in advance

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

YearQty Qty 91- Days LY
2023130000105000
2022136000 
   
DateQty 
9/10/20231000 
2/10/20232500 
25/09/20234000 
18/09/20235500 
11/09/20237000 
4/09/20238500 
28/08/202310000 
21/08/202311500 
14/08/202313000 
7/08/202314500 
31/07/202316000 
24/07/202317500 
17/07/202319000 
9/10/20221000 
2/10/20222000 
25/09/20223000 
18/09/20224000 
11/09/20225000 
4/09/20226000 
28/08/20227000 
21/08/20228000 
14/08/20229000 
7/08/202210000 
31/07/202211000 
24/07/202212000 
17/07/202213000 
10/07/202214000 
17/07/202215000 
24/07/202216000 

Hmm, not getting the same result.

 

lbendlin_0-1697056294151.png

All of the 2022 transactions lie within the 91 day window.

Hi

 

Thank you that worked 

Hi

I'm sorry I tried to upload the sample PBIX file, I am using the code you provided.

 

Qty Last 91 Days LY =
var d = max('Calendar SP1'[Date])
return CALCULATE(SUM('Data Details'[Qty]),
SAMEPERIODLASTYEAR('Calendar SP1'[Date]),  
'Calendar SP1'[Date]>=EDATE(d,-12)
)
 
sue_mcc20_0-1697055065741.png

 

 

lbendlin
Super User
Super User

Qty Last 91 Days LY = 
var d = max('Calendar SP1'[Date])
return CALCULATE(SUM('Data Details'[ Qty]),
SAMEPERIODLASTYEAR('Calendar SP1'[Date]),  
'Calendar SP1'[Date]>=EDATE(d,-12)
)

Helpful resources

Announcements
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