exam questions

Exam PL-300 All Questions

View all questions & answers for the PL-300 exam

Exam PL-300 topic 2 question 29 discussion

Actual exam question from Microsoft's PL-300
Question #: 29
Topic #: 2
[All PL-300 Questions]

HOTSPOT -
You are enhancing a Power BI model that has DAX calculations.
You need to create a measure that returns the year-to-date total sales from the same date of the previous calendar year.
Which DAX functions should you use? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: CALCULATE -
Example:
Total sales on the last selected date =
CALCULATE (
SUM ( Sales[Sales Amount] ),
'Sales'[OrderDateKey] = MAX ( 'Sales'[OrderDateKey] )
)

Box 2: SUM -

Box 3: SAMEPERIODLASTYEAR -
SAMEPERIODLASTYEAR returns a set of dates in the current selection from the previous year.
Example:
-- SAMEPERIODLASTYEAR returns the selected period shifted back one year.

EVALUATE -
VAR StartDate = DATE ( 2008, 07, 25 )
VAR EndDate = DATE ( 2008, 07, 31 )

RETURN -
CALCULATETABLE (
SAMEPERIODLASTYEAR ( 'Date'[Date] ),
'Date'[Date] >= StartDate &&
'Date'[Date] <= EndDate
)
ORDER BY [Date]
Reference:
https://docs.microsoft.com/en-us/dax/calculate-function-dax
https://dax.guide/sameperiodlastyear/

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
Muffinshow
Highly Voted 2 years, 4 months ago
Calculate Sum DatesBetween
upvoted 191 times
...
alena2k
Highly Voted 2 years, 4 months ago
Calculate Sum DatesBetween Suggested SamePeriodLastYear expects only 1 parameter: column containing dates
upvoted 65 times
RichardOgoma
2 years, 3 months ago
Good explanation
upvoted 6 times
...
...
GiuseppeTanda
Most Recent 1 month, 2 weeks ago
The last one is datesbetween: from MS documentation DATESBETWEEN(<Dates>, <StartDate>, <EndDate>). SAMEPERIODLASTYEAR(<dates>) takes only 1 mandatory argument
upvoted 1 times
...
jaume
1 month, 3 weeks ago
CALCULATE SUM DATESBETWEEN it could be misleading the "startyear" and "endate" labels as there is no explicit mention this VARS (calculated above in the DAX expression) are retuning PREVIOUS YEAR startdate and enddate. Also, as mentioned by several others, the SAMEPERIODLASTYEAR function requires one single argument ([Date])
upvoted 3 times
...
rcaliandro
4 months, 4 weeks ago
You can use SAMEPERIODLASTYEAR but in this case 3 arguments are required so we need to use DatesBetween because there are three arguments. So I would say: CALCULATE, SUM, DATESBETWEEN
upvoted 2 times
...
acvribeiro
1 year, 2 months ago
Calculate Sum DatesBetween -- I always look for the number of arguments necessary: DATESBETWEEN(<Dates>, <StartDate>, <EndDate>) SAMEPERIODLASTYEAR(<dates>)
upvoted 10 times
...
Elfmo11
1 year, 4 months ago
CALCULATE, SUM and DATESBETWEEN. DATESBETWEEN because the variables that are declared already contain the dates of last year.
upvoted 5 times
...
Igetmyrole
1 year, 4 months ago
Calculate Sum Datesbetween
upvoted 3 times
...
Mabuse1
1 year, 6 months ago
Who decides on website's final answer? We need to understand his/her level of confidence. Maybe he got the answers from Microsoft.
upvoted 12 times
...
arnoh
1 year, 6 months ago
The location of the formula text in between the images is a bit poorly chosen. It makes it seem like the order is: Option box 1 > ( Sales [sales] ), Option box 2. Even though that wouldn't obviously be possible
upvoted 1 times
...
tke44
1 year, 7 months ago
hmm thanks for the explanation. Calculate, sum, datesBetween
upvoted 1 times
...
ahhida
1 year, 8 months ago
Calculate Sum DatesBetween
upvoted 1 times
...
RazaTheLegend
1 year, 9 months ago
Correct Answer : Calculate, Sum, and DateBetween The DATESBETWEEN function is used to filter a table or a column of dates to a specified date range. It takes two arguments: the first argument is the date column to filter, and the second and third arguments are the start and end dates of the desired date range, respectively. The function returns a table of dates that fall within the specified range. On the other hand, the SAMEPERIODLASTYEAR function is used to retrieve the same period (week, month, quarter, or year) as the one currently selected, but from the previous year. It takes one argument, which is the date column to use as a reference, and returns a table of dates from the previous year that match the current period. This function is often used to compare data across time periods, such as comparing sales in the current year to sales in the same period of the previous year.
upvoted 14 times
...
SanaCanada
1 year, 9 months ago
Correct Answer : Calculate, Sum, and DateBetween The DATESBETWEEN function is used to filter a table or a column of dates to a specified date range. It takes two arguments: the first argument is the date column to filter, and the second and third arguments are the start and end dates of the desired date range, respectively. The function returns a table of dates that fall within the specified range. On the other hand, the SAMEPERIODLASTYEAR function is used to retrieve the same period (week, month, quarter, or year) as the one currently selected, but from the previous year. It takes one argument, which is the date column to use as a reference, and returns a table of dates from the previous year that match the current period. This function is often used to compare data across time periods, such as comparing sales in the current year to sales in the same period of the previous year. No confusion, and no need to further discussion
upvoted 5 times
...
SanaCanada
1 year, 10 months ago
Answer is correct Calculate Sum Sameperiodlstyear no confusion
upvoted 1 times
Burabari
1 year, 8 months ago
The start and end dates has already been calculated in the parameters so DATESBETWEEN is the answer. Using SAMEPERIODLASTYEAR would go an extra year back.
upvoted 4 times
...
...
Pinha
1 year, 10 months ago
Calculate Sum DatesBetween * Sales Last Year = CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR(Date[Date])) * Total Sales Q1 = CALCULATE(SUM(Sales[Amount]), DATESBETWEEN(Sales[Date], DATE(2022,1,1), DATE(2022,3,31))) * DatesBetween expects 3 parameters as per the exhibit, SamePeriodLastYear expects one parameter
upvoted 7 times
...
Mati_123
1 year, 10 months ago
Calculate Sum DatesBetween
upvoted 1 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