Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
Im new to Power BI and DAX. Really appreciate for some help. I used SAMEPERIODLASTYEAR function to refer back to the Sales Last Year. But Im getting the 28th Feb 2023 sales value reflected as last year's sales for 29th Feb 2024 even though the day 29th Feb 2023 doesnot exists. Is there a work around this to display that value blank when such dates doesnot exists?
Thanks in advance.
@dataandme this is the expected behaviour, sameperiodlastyear compares day with day hence 29th is considered, please refer this DAX to handle 29th data,
Sales PY :=
if( hasonevalue(DateDimension[Date]),
var __currentDate = max(DateDimension[Date])
var __shouldCalculate =
month(__currentDate) <> 2
&& day(__currentDate) <> 29
var __result =
if(__shouldCalculate,
CALCULATE(
[System Sales],
DATEADD(DateDimension[Date],-1,YEAR)
)
)
return
__result
)
Hi @raji_n,
Thank you for the DAX, but now the entire month of Feb is vanishing rather than just 29th Feb.
Hi @raji_n
Now, its skipping 29 Feb 2024 which is good but giving me only the PY Sales for Feb.
User | Count |
---|---|
21 | |
14 | |
11 | |
7 | |
5 |
User | Count |
---|---|
23 | |
23 | |
20 | |
15 | |
10 |