Forum Discussion
TOTALYTD is not working
I loaded factinternetsales from adventureworks2016 database into powerbi. created totalytd column using following dax formula.
TOTALYTD= TOTALYTD(sum(FactInternetSales[SalesAmount]),FactInternetSales[OrderDate].[Date])
the above dax is not working. please find the below screenshot.
- Anonymous5 years ago
Hi SivaReddy ,
Try this formula.
Measure = CALCULATE(SUM('Table'[sales]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(SELECTEDVALUE('Table'[date]))&&'Table'[date]<=MAX('Table'[date])))Best Regards,
Jay
4 Replies
- Samarth_18
Community Champion
Hi SivaReddy ,
If you have calender table/date table which connected to FactInternetSales table then pass date column from calender/date table into totalytd function.
TOTALYTD ( SUM ( FactInternetSales[SalesAmount] ), Calender_table[Date] )or you can try below code:-
TOTALYTD = CALCULATE ( SUM ( FactInternetSales[SalesAmount] ), YEAR ( FactInternetSales[OrderDate] ) = YEAR ( NOW () ) )Thanks,
Samarth
- SivaReddyFrequent Visitor
I used fulldatealternativekey of dimdate. Still I am not getting ytd. please find the below screenshot.
dax formula used is TotalYTD = TOTALYTD(sum(FactInternetSales[SalesAmount]),DimDate[FullDateAlternateKey].[Date])
- Samarth_18
Community Champion
What about below code?
TOTALYTD = CALCULATE ( SUM ( FactInternetSales[SalesAmount] ), YEAR ( FactInternetSales[OrderDate] ) = YEAR ( NOW () ) )
- AnonymousNot applicable
Hi SivaReddy ,
Try this formula.
Measure = CALCULATE(SUM('Table'[sales]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(SELECTEDVALUE('Table'[date]))&&'Table'[date]<=MAX('Table'[date])))Best Regards,
Jay