๐ Power BI Interview Challenge #4 ๐ฅ
๐๐ป๐๐ฒ๐ฟ๐๐ถ๐ฒ๐๐ฒ๐ฟ:
You have 2 minutes to solve this Power BI problem.
You have a Sales table with the following columns:
Product
Sales
Create a DAX measure to calculate the percentage contribution of each product to total sales.
๐ ๐ฒ: Challenge accepted! ๐ช
Sales Contribution % =
DIVIDE(
[Total Sales],
CALCULATE(
[Total Sales],
ALL(Sales[Product])
),
0
)
๐ก Explanation:
This measure calculates how much each product contributes to the total sales.
โข [Total Sales] returns the sales for the current product.
โข ALL(Sales) removes the product filter while keeping other filters intact.
โข CALCULATE() recalculates the total sales after removing the product filter.
โข DIVIDE() safely performs the division and avoids divide-by-zero errors.
This challenge tests your understanding of:
โ
CALCULATE()
โ
ALL()
โ
DIVIDE()
โ
Filter Context
โ
Percentage Calculations
๐ฏ Expected Output Example
Product | Sales | Sales Contribution %
Laptop | 50,000 | 50%
Mouse | 20,000 | 20%
Keyboard | 15,000 | 15%
Monitor | 15,000 | 15%
๐ Bonus (Dynamic Percentage by Selected Filters)
Sales Contribution % =
DIVIDE(
[Total Sales],
CALCULATE(
[Total Sales],
ALLSELECTED(Sales[Product])
),
0
)
Using ALLSELECTED() respects slicers and page filters while removing only the product filter, making the measure more interactive.
๐ Tip for Power BI Job Seekers:
Understanding the difference between these functions is crucial for interviews:
โข ALL() โ Removes all filters from the specified column or table.
โข ALLSELECTED() โ Respects user selections made through slicers and filters.
โข REMOVEFILTERS() โ Modern alternative to remove filters in many scenarios.
These are among the most frequently asked DAX concepts in Power BI interviews.
Power BI Resources: https://whatsapp.com/channel/0029Vai1xKf1dAvuk6s1v22c
โค๏ธ React with โค๏ธ for more Power BI interview challenges!
Post #2959
6.58K
- โค 14