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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
IAmCare
Frequent Visitor

SamePeriodLastYear when fiscal month ends on last Saturday of the month

Is there a way to use the SAMEPERIODLASTYEAR function in Power BI when your fiscal calendar does not go month to month? Our monthly calendar ends on the last Saturday of the month. So

September 2017 StartDate is 8/28/2016 and ends on 9/24/2016

September 2018 StartDate is 8/27/2017 an ends on 9/30/2017

This is what I have

Last = CALCULATE([Current],SAMEPERIODLASTYEAR('DimDate'[Date]))

Current = CALCULATE(COUNTROWS('FactWholesale'))

 

Is there another way to get this to work other than SamePeridLastMonth?  This is what I am getting pic.png

I had posted this a couple days ago but did not understand what was going on when I posted it. I see it now but dont know how to fix it.  ANY HELP will be MUCH APPRECIATED.

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi IAmCare,

 

As a general solution, you can create a measure using DAX as below:

 

Last =
VAR one_fiscal_month_ago =
MAX ( FactWholesale[Date] ) - MAX ( FactWholesale[EndDate] )
+ MAX ( FactWholesale[StartDate] )
RETURN
CALCULATE (
COUNTROWS ( FactWholesale ),
FILTER (
FactWholesale,
FactWholesale[Date] >= one_fiscal_month_ago
&& FactWholesale[Date] <= MAX ( FactWholesale[Date] )
)
)

Regards,

Jimmy Tao

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

Hi IAmCare,

 

As a general solution, you can create a measure using DAX as below:

 

Last =
VAR one_fiscal_month_ago =
MAX ( FactWholesale[Date] ) - MAX ( FactWholesale[EndDate] )
+ MAX ( FactWholesale[StartDate] )
RETURN
CALCULATE (
COUNTROWS ( FactWholesale ),
FILTER (
FactWholesale,
FactWholesale[Date] >= one_fiscal_month_ago
&& FactWholesale[Date] <= MAX ( FactWholesale[Date] )
)
)

Regards,

Jimmy Tao

v-yuta-msft
Community Support
Community Support

Hi IAmCare ,

 

Power bi can't achieve the last Saturday of every month automatically, so I would recommend you to create a 'Fiscal Canlendar' tableand input the start date and end date every month to that table. Then create a relationship between two tables. 

 

Regards,

Jimmy Tao

 

Hi Jimmy,   My DimDate has fiscal month start and end dates in it.

How can I use this to get what I need?

Thank you for your response.

 

This is what I am trying to get to work.

Current = CALCULATE(COUNTROWS('FactWholesale'))

Last = CALCULATE([Current],SAMEPERIODLASTYEAR('DimDate'[Date]))

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.