pl-300 Practice Question 1928

Exam: pl-300
Domain: Prepare the data
Topic: Clean, transform, and load the data
Difficulty: medium
During a data transformation task, you encounter a dataset where certain columns need to be pivoted to transform rows into columns. For example, you have a dataset with a column named 'Category' and a column named 'Value', and you need to pivot the 'Category' column so that each unique category becomes a separate column with its corresponding value. Which M language function would you use to accomplish this transformation?

Answer Options

A
unpivot
B
pivot
C
flatten
D
split

Correct Answer

B: pivot

Explanation

The correct answer is B because the `pivot` function in M is used to transform rows into columns based on a specified column. It takes two arguments: the column to pivot and the column to aggregate the values by. Option A uses `unpivot`, which is the opposite of what is needed. Option C uses `flatten`, which is used to expand nested arrays or records. Option D uses `split`, which is used to divide strings into smaller parts.

Related Practice Questions