nerdexam
MicrosoftMicrosoft

DP-500 · Question #133

DP-500 Question #133: Real Exam Question with Answer & Explanation

This question tests knowledge of Power Query M language syntax for defining custom reusable functions, specifically creating a Fahrenheit-to-Celsius converter using the correct formula and function declaration structure.

Query and transform data

Question

QUESTION 178 Hotspot Question You use Power Query Editor to transform data. You need to create a function named ConvertF2C that accepts a temperature value in Fahrenheit and returns a temperature value in Celsius. How should you complete the code? To answer, select the appropriate options in the answer area. NOTE: Each correct selection is worth one point.

Explanation

This question tests knowledge of Power Query M language syntax for defining custom reusable functions, specifically creating a Fahrenheit-to-Celsius converter using the correct formula and function declaration structure.

Approach. In Power Query Editor, custom functions are written in the M language using the syntax: (parameterName as type) as returnType => expression. For ConvertF2C, the correct code is (Fahrenheit as number) as number => (Fahrenheit - 32) * (5/9). The Fahrenheit-to-Celsius formula is C = (F − 32) × 5/9. The function is then named by assigning it in a let...in block: let ConvertF2C = (Fahrenheit as number) as number => (Fahrenheit - 32) * (5 / 9) in ConvertF2C. Key elements are: the parameter with type annotation (as number), the return type annotation after the closing parenthesis, the fat-arrow => operator to define the function body, and the correct arithmetic formula.

Concept tested. Power Query M language custom function syntax - specifically parameter typing, return type declaration, the fat-arrow => function definition operator, and applying the Fahrenheit-to-Celsius mathematical formula (C = (F − 32) × 5/9) within a named function.

Reference. Microsoft Learn - Create a custom function in Power Query: https://learn.microsoft.com/en-us/power-query/custom-function

Topics

#Power Query#M language#Custom Functions#Data Transformation

Community Discussion

No community discussion yet for this question.

Full DP-500 PracticeBrowse All DP-500 Questions