๐ Power BI Interview Challenge #2 ๐ฅ
๐๐ป๐๐ฒ๐ฟ๐๐ถ๐ฒ๐๐ฒ๐ฟ:
You have 2 minutes to solve this Power BI problem.
You have a Sales table with the columns: Order Date & Sales
Create a DAX measure to calculate Month-to-Date (MTD) Sales.
๐ ๐ฒ: Challenge accepted! ๐ช
MTD Sales =
TOTALMTD(
SUM(Sales[Sales]),
Sales[Order Date]
)
๐ก Explanation:
โข TOTALMTD() calculates cumulative sales from the beginning of the current month up to the selected date.
โข SUM(Sales) returns the total sales amount.
โข Sales[Order Date] is the date column used for the MTD calculation.
โข The measure automatically resets at the beginning of each new month.
๐ฏ Expected Output Example
Date | Sales | MTD Sales
Jul 1 | 2,000 | 2,000
Jul 2 | 3,500 | 5,500
Jul 3 | 1,500 | 7,000
Jul 4 | 4,000 | 11,000
๐ Bonus (Using a Calendar Table)
MTD Sales =
TOTALMTD(
[Total Sales],
'Calendar'[Date]
)
Using a dedicated Calendar table improves model performance and ensures accurate time intelligence calculations.
๐ Tip for Power BI Job Seekers:
Always create a proper Date Table and mark it as a Date Table in Power BI before using Time Intelligence functions. Many interview questions are designed to test this best practice.
Power BI Resources: https://whatsapp.com/channel/0029Vai1xKf1dAvuk6s1v22c
โค๏ธ React with โค๏ธ for more Power BI interview challenges!
Post #2954
5.77K
- โค 8