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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

Power BI Carousel June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.