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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.