Forum Discussion
Dax problem
Is it possible that YTD and QTD result comes same ???
I have created dax for YTD = TotalYTD(sumx(sales, sales), orderdate.[date])
and for QTD = TotalQTD( sumx(sales,sales), orderdate.[date])
Please let me know, why I am not getting the different result?
3 Replies
- FowmySuper User
Anonymous
Yes, it is possible in the 1st quarter.
You need to provide the name of a column containing dates or a one-column table containing dates. The SUMX also needs to be corrected.
Your measure shoudl go like: YTD = TOTALYTD ( SUMX ( sales, sales[value] ), dates[date] )
You can create a calendar table with the following code. Change the date range as required.Dates =
ADDCOLUMNS(
CALENDAR("01/01/2020","31/12/2021"),
"Month", MONTH([Date]),
"Month Name", FORMAT([Date],"Mmmm"),
"Year", YEAR([Date]),
"Year Month No", YEAR([Date]) * 100 + MONTH([Date]),
"Year Month" , FORMAT([Date] , "Mmm yyyy" )
)
- AnonymousNot applicable
It hasn't worked still I am getting the same result.
and with the master calendar, QTD becomes blank.
what to do??
- AnonymousNot applicable
Hi Anonymous ,
Have you placed the measure in the card.
You need to use Date and measure together to display data:
The TOTALYTD() function indicates that the data from the beginning of the year to today is accumulated.
The TOTALQTD() function indicates that the quarter-to-date date is calculated in the current context.
So the values of the two functions are the same in the first quarter. After the second quarter, the TOTALYTD() function will continue to accumulate, and TOTALQTD() will be grouped according to the quarter and start to accumulate again.
You can try to change the function to:
TOTALQTD = TOTALQTD(SUM('sales'[value]),'GG'[Date])If it does not meet your expected results, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.