You have a Power BI model for sales data. You create a measure to calculate the year-to-date sales. You need to compare the year-to-date sales with the previous year for the same time period. Which DAX function should you use?
No, you cannot use DataAdd.
If you use DateAdd, you have the whole previous year calculated.
If you want to calculate the same period of the previous year, you should use SAMEPERIODLASTYEAR.
_SAMEPERIODLASTYEAR =
CALCULATE(
SUM(Invoices[Amount]); SAMEPERIODLASTYEAR(DATESYTD(blabla[Date]))
)
not True . DATEADD subtracts/adds interval specified in Parameter to given date . So if You write DATEADD(date[date],-1,year) . it will move the year back by 1 for that date . which is same what SAMEPeriodLastYear does .BUT with DATEADD you can do more , you can adjust months/days/quarter .
Correct. Both SAMEPERIODLASTYEAR and DATEADD are correct answers. Refer to https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax: it is clearly stated: "the dates returned are the same as the dates returned by this equivalent formula: DATEADD(dates, -1, year)"
However I believe C is a little bit better here because SAMEPERIODLASTYEAR is simpler and maybe a little bit easier to understand for maintenance purposes. I would go with C
1st already existing measure to calculate ytd sales:
YtdSales = CALCULATE(SUM(FactInternetSales[SalesAmount]), DATESYTD(FactInternetSales[DueDate]))
To be able to compare you need to create a 2nd measure to calculate ytd sales same period previous year:
YtdSalesSamePeriodLastYear = CALCULATE([YtdSales], SAMEPERIODLASTYEAR(FactInternetSales[DueDate]))
So, answer C is correct.
I think datesytd is a correct answer. I am not sure about that.
my observations are
1. dateadd and sameperiodlastyear work same when u are calculating total sales for last year. The diff b/w the above two is, dateadd can go more than one year back or forward,but sameperiodlastyear only go one year back.
In the question they want to compare the value with previous year only. Hence both r same.
2.They are comparing ytd value,not a total sales
I think dax function looks like
calculate(totalsales,datesytd(sameperiodlastyear('date'[date]))
No, they won't get the same results. PREVIOUSYEAR returns the full year, 12 months. SAMEPERIODLASTYEAR returns corresponding period for the last year. I you have YTD measure for Jan-June, then this function will return corresponding period, that is Jan-June of previous year. There are subtle differences between functions, which you may find in the web. SAMEPERIODLASTYEAR is the correct answer here.
upvoted 13 times
...
...
This section is not available anymore. Please use the main Exam Page.70-778 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Seyed
Highly Voted 5 years, 3 months agocalibear
5 years, 3 months agoamar111
5 years, 1 month agoFrdFrd
4 years, 4 months agosjonghe
Most Recent 4 years, 7 months ago123
4 years, 10 months agosananthi
4 years, 11 months agoRicky7876
5 years, 3 months agoraspberry
5 years, 2 months ago