The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I am struggling to calculate ytd for the selected year & month and previous year YTD for the same selected month in filter.
For example, if i select FY 2023 YTD July in filter, it should provide me the year to date value starts from Jan 2023 upto July 2023. And it should also provide me the previous year to date value starts from Jan 2022 upto July 2022.
Solved! Go to Solution.
Hi @insandur ,
Please try the following methods and check if they can solve your problem:
1.Create the simple table.
2.Select the slicer visual and drag the month into the visual.
3.Select the slicer visual and drag the year into the visual.
4.Create the measure to calculate YTD.
YTD = CALCULATE (
SUM ('Table'[Values]),
FILTER (
ALL ('Table'),
'Table'[Year] = SELECTEDVALUE('Table'[Year])
&& 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
)
)
5.Create the measure to calculate previous YTD .
pre_YTD = CALCULATE (
SUM ('Table'[Values]),
FILTER (
ALL ('Table'),
'Table'[Year] = (SELECTEDVALUE('Table'[Year]) - 1)
&& 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
)
)
6.Drag the measure into the card visual. The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @insandur ,
Please try the following methods and check if they can solve your problem:
1.Create the simple table.
2.Select the slicer visual and drag the month into the visual.
3.Select the slicer visual and drag the year into the visual.
4.Create the measure to calculate YTD.
YTD = CALCULATE (
SUM ('Table'[Values]),
FILTER (
ALL ('Table'),
'Table'[Year] = SELECTEDVALUE('Table'[Year])
&& 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
)
)
5.Create the measure to calculate previous YTD .
pre_YTD = CALCULATE (
SUM ('Table'[Values]),
FILTER (
ALL ('Table'),
'Table'[Year] = (SELECTEDVALUE('Table'[Year]) - 1)
&& 'Table'[Month] <= SELECTEDVALUE('Table'[Month])
)
)
6.Drag the measure into the card visual. The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi @insandur
you can also try with explicit measures:
1. Total YTD
Total YTD =
CALCULATE(
SUM ( 'Fact'[Value] ),
DATESYTD('Calendar'[Date])
)
2. Total PYTD
Total PYTD =
CALCULATE(
[Total YTD],
DATEADD(
'Calendar'[Date],-1,YEAR)
)
)
Hope it helps.
Please try the "Running totals" Quick Measure.
User | Count |
---|---|
27 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
11 | |
7 |