Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello Experts,
I am currently facing challenges in obtaining the correct output as per my requirement in Power BI.
I have a dimension table in the following format:
Column1,Column2,Column3,Column4
samsung1,Samsung,Tier 1,Partnered
samsung2,Samsung,Tier 1,Partnered
sony,Sony,Tier 2,Non-Partner
Google,Google,Tier 2,Partnered
Microsoft,Microsoft,Tier 1,Non-Partner
I have Fact table in the below format
Column1,Sales
samsung1,22
samsung2,10
sony,25
Google,22
Microsoft,9
The required output should be like below
Category,Sales
Samsung,32
Sony,25
Google,22
Microsoft,9
Tier 1,41
Tier 2,47
Total Tier,88
Partnered,54
Non-Partner,34
Total Partnere/Non-Partnered,88
The category values are derived from Column 2, Column 3, and Column 4 based on the following business conditions:
The top category values should be taken from Column 2 first, followed by Column 3, and finally from Column 4.
The values in Column 2 should be sorted based on sales numbers.
Within Column 3, Tier 1 categories should appear first, followed by Tier 2 categories.
Categories labeled as "Partnered" should be placed above "Non-Partner" categories, which should be at the bottom.
I have been struggling with this design for the past two days. Can anyone help me achieve the desired output?
Solved! Go to Solution.
@mantukumar Hi, You need to create a calculated table in Power BI that aggregates data based on your business rules and provides sorting as required. Here's how you can approach this:
Create a summarized table using DAX that aggregates sales based on different category levels (Column2, Column3, Column4).
Apply sorting rules to display the values in the required orde
Go to Modeling → New Table and enter the following DAX:
CategorySales =
VAR CategorySalesTable =
UNION (
SUMMARIZE ( FactTable, DimTable[Column2], "Sales", SUM ( FactTable[Sales] ) ),
SUMMARIZE ( DimTable, DimTable[Column3], "Sales", SUMX ( RELATEDTABLE ( FactTable ), FactTable[Sales] ) ),
SUMMARIZE ( DimTable, DimTable[Column4], "Sales", SUMX ( RELATEDTABLE ( FactTable ), FactTable[Sales] ) )
)
VAR FinalTable =
ADDCOLUMNS (
CategorySalesTable,
"SortOrder",
SWITCH (
TRUE (),
DimTable[Column3] = "Tier 1", 1, // Tier 1 first
DimTable[Column3] = "Tier 2", 2, // Then Tier 2
DimTable[Column4] = "Partnered", 3, // Partnered next
DimTable[Column4] = "Non-Partner", 4 // Non-Partner last
)
)
RETURN FinalTable
Go to Model View in Power BI.
Select the Category column in the newly created table.
Click on "Sort by Column" and select SortOrder.
This ensures that Tier 1 comes first, then Tier 2, followed by Partnered, and finally Non-Partnered.
Add a Table Visual in Power BI.
Use the Category column from the CategorySales
table.
Use the Sales measure.
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Hi @mantukumar,
Thank you for using Microsoft Fabri cCommunity Forum and Thankyou @johnbasha33 for your response to the query.
Clarification of two questions:
To apply additional conditions, such as filtering by a specific year, region, or product category, you should use the CALCULATE() function inside SUM(). This ensures that the aggregation considers the specified conditions.
Here is an example of the DAX formula:
CALCULATE(
SUM ( FactTable[Sales] ),
FactTable[Year] = 2024,
FactTable[Region] = "USA"
)
To display the total sales for Tiers (Tier1 + Tier2) and Partner Categories (Partnered + Non-Partnered), we need to calculate these values separately and include them in the final table.
Here is an example of the DAX formula:
VAR TotalTierSales =
CALCULATE (
SUM ( FactTable[Sales] ),
DimTable[Column3] IN { "Tier 1", "Tier 2" }
)
VAR TotalPartnerSales =
CALCULATE (
SUM ( FactTable[Sales] ),
DimTable[Column4] IN { "Partnered", "Non-Partner" }
)
VAR FinalTable =
UNION (
CategorySalesTable,
ROW ( "Category", "Total Tier", "Sales", TotalTierSales ),
ROW ( "Category", "Total Partnered/Non-Partnered", "Sales", TotalPartnerSales )
)
RETURN FinalTable
Hope this helps for your clarification. Please Accept as solution if this meets your needs and a Kudos would be appreciated.
Thank you.
What if we want to have similar table having too many measures for example sales, revenue, backlog, pipeline, cost etc , is it still best way to use summary table or there are any other way as well?
Hi @mantukumar,
To handle multiple measures like sales, revenue, backlog, pipeline, and cost in Power BI, you can create individual measures for each metric and then summarize the data based on your categories (Column2, Column3, Column4). Apply sorting logic to ensure the categories are displayed in the required order, such as prioritizing Tier 1 over Tier 2 and Partnered over Non-Partnered. Calculate the total values for different tiers and partner categories to display overall totals. Finally, create a table visual in Power BI using the summarized data, ensuring the sorting logic is applied to maintain the desired order.
This approach helps you efficiently organize and display multiple measures while maintaining the required sorting and aggregation logic.
Hope this helps for your clarification. Please Accept as solution if this meets your needs and a Kudos would be appreciated.
Regards,
Sahasra.
@mantukumar Hi, You need to create a calculated table in Power BI that aggregates data based on your business rules and provides sorting as required. Here's how you can approach this:
Create a summarized table using DAX that aggregates sales based on different category levels (Column2, Column3, Column4).
Apply sorting rules to display the values in the required orde
Go to Modeling → New Table and enter the following DAX:
CategorySales =
VAR CategorySalesTable =
UNION (
SUMMARIZE ( FactTable, DimTable[Column2], "Sales", SUM ( FactTable[Sales] ) ),
SUMMARIZE ( DimTable, DimTable[Column3], "Sales", SUMX ( RELATEDTABLE ( FactTable ), FactTable[Sales] ) ),
SUMMARIZE ( DimTable, DimTable[Column4], "Sales", SUMX ( RELATEDTABLE ( FactTable ), FactTable[Sales] ) )
)
VAR FinalTable =
ADDCOLUMNS (
CategorySalesTable,
"SortOrder",
SWITCH (
TRUE (),
DimTable[Column3] = "Tier 1", 1, // Tier 1 first
DimTable[Column3] = "Tier 2", 2, // Then Tier 2
DimTable[Column4] = "Partnered", 3, // Partnered next
DimTable[Column4] = "Non-Partner", 4 // Non-Partner last
)
)
RETURN FinalTable
Go to Model View in Power BI.
Select the Category column in the newly created table.
Click on "Sort by Column" and select SortOrder.
This ensures that Tier 1 comes first, then Tier 2, followed by Partnered, and finally Non-Partnered.
Add a Table Visual in Power BI.
Use the Category column from the CategorySales
table.
Use the Sales measure.
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Hi John,
Thanks for the solution.
Two questions:
1. What if SUM ( FactTable[Sales] ) has more conditions?
2. How to display total for column 2 (Tier1+Tier2) and column3 (Partnere + Non-partnered) values as per the requirement
Hi @mantukumar,
Thank you for using Microsoft Fabri cCommunity Forum and Thankyou @johnbasha33 for your response to the query.
Clarification of two questions:
To apply additional conditions, such as filtering by a specific year, region, or product category, you should use the CALCULATE() function inside SUM(). This ensures that the aggregation considers the specified conditions.
Here is an example of the DAX formula:
CALCULATE(
SUM ( FactTable[Sales] ),
FactTable[Year] = 2024,
FactTable[Region] = "USA"
)
To display the total sales for Tiers (Tier1 + Tier2) and Partner Categories (Partnered + Non-Partnered), we need to calculate these values separately and include them in the final table.
Here is an example of the DAX formula:
VAR TotalTierSales =
CALCULATE (
SUM ( FactTable[Sales] ),
DimTable[Column3] IN { "Tier 1", "Tier 2" }
)
VAR TotalPartnerSales =
CALCULATE (
SUM ( FactTable[Sales] ),
DimTable[Column4] IN { "Partnered", "Non-Partner" }
)
VAR FinalTable =
UNION (
CategorySalesTable,
ROW ( "Category", "Total Tier", "Sales", TotalTierSales ),
ROW ( "Category", "Total Partnered/Non-Partnered", "Sales", TotalPartnerSales )
)
RETURN FinalTable
Hope this helps for your clarification. Please Accept as solution if this meets your needs and a Kudos would be appreciated.
Thank you.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
72 | |
68 | |
41 | |
35 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
42 |