Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi all
I have the following table:
I am doing the sum of YTD and I am trying to compare it with the same period of last year (2023) but the values for PY YTD are wrong:
The dax for YTD (correct dax) is:
YTD AC =
CALCULATE(
SUM(
'Query1 (AC)'[[Units])
,DATESYTD(
'Query1 (AC)'[Date])
)
And for PY (not calculating correctly) is:
PY YTD AC =
CALCULATE(
SUM(
'Query1 (AC)'[[Units]),
SAMEPERIODLASTYEAR(
Query1[Date]
)
)
Any idea how to fix?
Thanks.
Solved! Go to Solution.
PBI file attached.
Hope this helps.
Hi,
Try this approach
Total = SUM('Query1 (AC)'[[Units])Total YTD = CALCULATE([Total],DATESYTD(Calendar[Date],"31/12"))Total YTD SPLY = calculate([Total YTD],sameperiodlastyear(calendar[date]))
Hope this helps.
Your measures worked, but if I click on the 2024 year, the PY values wont appear on the column "PY YTD AC"
How can I reflect the sales for Jan 2023 and Feb 2023 next to the Jan 2024 and Feb 2024 rows of the table intead of blanks?
The other thing that caught my attention was the the matrix on the right says the following:
I attach pbix:
Thanks a lot.
You have not followed any of the steps which i mentioend in my previous post. I do not see any Calendar Table at all. Read and implement properly.
Sorry about that, here is the pbix updated.
I created the calendar table with the columns you mentioned from my power query.
Still not showing the PY value and the matrix gives the error.
Can you please have a look? sample_sameperiod.pbix
Thanks.
You are welcome.
Hi @o59393,
Please find the below solution:
Measure 1= YTD = CALCULATE( SUM('My table'[Units]), DATESYTD('My table'[Date]) ) Measure 2= YTD LY = CALCULATE ( [YTD], SAMEPERIODLASTYEAR('My table'[Date]) ) |
********************Please accept this as a solution***************************
I got values repeated:
Dax used:
PY YTD AC =
CALCULATE(
[YTD AC],
SAMEPERIODLASTYEAR(
Query1[Date]
)
)
Just in case, my dates are always 1/1/2023, 2/1/2023, 3/1/2023.... 2/1/2024
Appreciate your help
@o59393 could you please sahe a sample file. I think this will help to support you?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 51 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 72 | |
| 70 | |
| 39 | |
| 34 | |
| 23 |