exam questions

Exam 70-778 All Questions

View all questions & answers for the 70-778 exam

Exam 70-778 topic 1 question 84 discussion

Actual exam question from Microsoft's 70-778
Question #: 84
Topic #: 1
[All 70-778 Questions]

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?

  • A. LASTDATE
  • B. TOTALYTD
  • C. SAMEPERIODLASTYEAR
  • D. PREVIOUSYEAR
  • E. DATEADD
  • F. DATESVTD
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Seyed
Highly Voted 5 years, 3 months ago
we can also use DATEADD! CALCULATE([YTDSALSE],DATEADD(DIMDATE[DATE],-1,YEAR))
upvoted 7 times
calibear
5 years, 3 months ago
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])) )
upvoted 4 times
amar111
5 years, 1 month ago
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 .
upvoted 6 times
FrdFrd
4 years, 4 months ago
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
upvoted 1 times
...
...
...
...
sjonghe
Most Recent 4 years, 7 months ago
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.
upvoted 3 times
...
123
4 years, 10 months ago
See question#114. Basically the same question, but has different opinions inc SAMEPERIODLASTYEAR and PREVIOUSYEAR
upvoted 2 times
...
sananthi
4 years, 11 months ago
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]))
upvoted 1 times
...
Ricky7876
5 years, 3 months ago
DATEADD, PREVIOUSYEAR, and SAMEPERIODLASTYEAR can all get you the same thing
upvoted 3 times
raspberry
5 years, 2 months ago
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
...
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago