Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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
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.
Solved! Go to Solution.
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
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
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]))
User | Count |
---|---|
102 | |
92 | |
85 | |
78 | |
71 |
User | Count |
---|---|
113 | |
104 | |
101 | |
73 | |
65 |