Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
We have a YTD measure as follows which works perfectly:
Solved! Go to Solution.
@willatkinson Your measure uses TODAY() which gives a fixed date, so it returns the same value regardless of the visual context. To make it work month-by-month in a visual, you need to use the date context from your visual instead of TODAY().
Replace with this:
Count of Case reference Previous YTD =
CALCULATE(
COUNTA('Table'[Case reference]),
FILTER(
ALL('DDT'[Date (DDT)]),
YEAR('DDT'[Date (DDT)]) = YEAR(MAX('DDT'[Date (DDT)])) - 1 &&
'DDT'[Date (DDT)] <= DATE(
YEAR(MAX('DDT'[Date (DDT)])) - 1,
MONTH(MAX('DDT'[Date (DDT)])),
DAY(MAX('DDT'[Date (DDT)]))
)
)
)
How this works:
MAX('DDT'[Date (DDT)]) gets the current date from your visual's filter context
To use in a visual:
This replaces the static TODAY() with dynamic date context from your visual.
Best regards!
PS: If you find this post helpful consider leaving kudos or mark it as solution
Hi,
Assuming you have a Calendar Table and you have a year slicer and you have months dragged to a Table/Matrix visual
C = COUNTA('Table'[Case reference])
YTD C = calculate([C],DATESYTD(Calendar[Date],"31/12"))
YTD C (PY) = calculate([YTD C],samperiodlastyear(calendar[Date]))
Hope this helps.
Hi @willatkinson,
I would also take a moment to thank @Mauro89 , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Regards,
Community Support Team.
Hi @willatkinson,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We are always here to support you.
Regards,
Community Support Team.
Hi,
Assuming you have a Calendar Table and you have a year slicer and you have months dragged to a Table/Matrix visual
C = COUNTA('Table'[Case reference])
YTD C = calculate([C],DATESYTD(Calendar[Date],"31/12"))
YTD C (PY) = calculate([YTD C],samperiodlastyear(calendar[Date]))
Hope this helps.
Hi @willatkinson,
you can try if these two measures work for your case. Check them with your actual data.
Option 1: Using SAMEPERIODLASTYEAR
Count of Case reference Previous YTD =
CALCULATE(
COUNTA('Table'[Case reference]),
DATESYTD(SAMEPERIODLASTYEAR('DDT'[Date (DDT)]))
)
Option 2: Using DATEADD
Count of Case reference Previous YTD =
CALCULATE(
[Count of Case reference YTD],
DATEADD('DDT'[Date (DDT)], -1, YEAR)
)
Best regards!
PS: If you find this post helpful consider leaving kudos or mark it as solution
Hi @Mauro89,
This didn't give me the figure I expected, but the following did:
CALCULATE(
COUNTA('Table'[Case reference]),
FILTER(
ALL('DDT'),
'DDT'[Date (DDT)] >= DATE(YEAR(TODAY()) - 1, 1, 1)
&& 'DDT'[Date (DDT)] <= DATE(YEAR(TODAY()) - 1, MONTH(TODAY()), DAY(TODAY()))
)
)
This gives me a year to date figure for the previous year, but I can only see a single figure, where I would like to see a month by month visual, how would this work?
@willatkinson Your measure uses TODAY() which gives a fixed date, so it returns the same value regardless of the visual context. To make it work month-by-month in a visual, you need to use the date context from your visual instead of TODAY().
Replace with this:
Count of Case reference Previous YTD =
CALCULATE(
COUNTA('Table'[Case reference]),
FILTER(
ALL('DDT'[Date (DDT)]),
YEAR('DDT'[Date (DDT)]) = YEAR(MAX('DDT'[Date (DDT)])) - 1 &&
'DDT'[Date (DDT)] <= DATE(
YEAR(MAX('DDT'[Date (DDT)])) - 1,
MONTH(MAX('DDT'[Date (DDT)])),
DAY(MAX('DDT'[Date (DDT)]))
)
)
)
How this works:
MAX('DDT'[Date (DDT)]) gets the current date from your visual's filter context
To use in a visual:
This replaces the static TODAY() with dynamic date context from your visual.
Best regards!
PS: If you find this post helpful consider leaving kudos or mark it as solution
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.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 40 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 70 | |
| 68 | |
| 32 | |
| 27 | |
| 25 |