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.
Hi everyone,
I am using two measures to sum up the amount of sales YTD (year to date) for current vs last year.
For example: Today is 10.10.24, so:
2024: sales from 01.01.24 to 10.10.24
2023: sales from 01.01.23 to 10.10.23
This is working perfectly when it is about 2024 (current year) vs 2023. But I also need to replicate the results for let's say 2023 vs 2022, 2022 vs 2021.
YTD_PartnerasTK = TOTALYTD(SUM('Dataset'[Sales]), 'Dim Datum'[Datum], 'Dim Datum'[Datum] <= TODAY()
PYTD_PartnerasTK = CALCULATE(SUM('Dataset'[Sales ]),
CALCULATETABLE(SAMEPERIODLASTYEAR(DATESYTD('Dim Datum'[Datum])), 'Dim Datum'[Datum] <= TODAY()
))
Solved! Go to Solution.
Hi @camiurrego0 ,
Do you want to show the total sales from the beginning of last year to this day last year? Here is my method for your reference.
LastYear_To_Today =
VAR last_today = FORMAT(DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),"MM/DD/YYYY")
VAR current_year = YEAR(MAX('Table'[Date]))
VAR LastYear_To_Today =
CALCULATE (
SUM ( 'Table'[Sale] ),
FILTER (
ALL('Table'),
FORMAT('Table'[Date],"MM/DD/YYYY") <= last_today &&
YEAR('Table'[Date])= current_year - 1
)
)
RETURN
IF( ISBLANK(LastYear_To_Today), 0, LastYear_To_Today )
Best regards,
Mengmeng Li
Hi @camiurrego0 ,
Do you want to show the total sales from the beginning of last year to this day last year? Here is my method for your reference.
LastYear_To_Today =
VAR last_today = FORMAT(DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),"MM/DD/YYYY")
VAR current_year = YEAR(MAX('Table'[Date]))
VAR LastYear_To_Today =
CALCULATE (
SUM ( 'Table'[Sale] ),
FILTER (
ALL('Table'),
FORMAT('Table'[Date],"MM/DD/YYYY") <= last_today &&
YEAR('Table'[Date])= current_year - 1
)
)
RETURN
IF( ISBLANK(LastYear_To_Today), 0, LastYear_To_Today )
Best regards,
Mengmeng Li
Add a filter
FORMAT(MAX('Dim Datum'[Datum]),"MMDD")<=FORMAT(TODAY(),"MMDD")
User | Count |
---|---|
11 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
23 | |
14 | |
13 | |
10 | |
8 |