Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
zero99
Frequent Visitor

Complex Need to calculate top box and top 2 box aggregation in line chart.

Hi All, 

 

I have data as follows:

 

Price_ExpensivePrice_NormalPrice_CheapPrice_Cheapest
  Somewhat UnlikelySomewhat Unlikely
   Somewhat Unlikely
  Extremely UnlikelyExtremely Unlikely
Extremely Likely   
Extremely LikelyExtremely LikelyExtremely LikelyExtremely Likely
Somewhat Likely   
Somewhat LikelySomewhat Likely  
Somewhat LikelySomewhat LikelySomewhat LikelySomewhat Likely
Somewhat UnlikelySomewhat LikelyExtremely Likely 
Somewhat Likely   
Extremely UnlikelyExtremely UnlikelyExtremely UnlikelyExtremely Unlikely
Extremely Likely   
Neutral   
  Somewhat UnlikelyNeutral
Extremely LikelyExtremely LikelyExtremely LikelyExtremely Likely
 Somewhat UnlikelyNeutralNeutral
  Extremely UnlikelyNeutral
Somewhat Likely   
 Somewhat UnlikelySomewhat UnlikelyNeutral
Somewhat UnlikelyNeutralNeutral 
Neutral   
Extremely Likely   
NeutralSomewhat LikelySomewhat LikelyExtremely Likely
Somewhat LikelySomewhat Likely  
Somewhat UnlikelyNeutralExtremely Likely 
   Somewhat Unlikely
  Somewhat UnlikelyNeutral

 

 

I need to create line chart to that show (Y axis) the percentage of extremely likely and aggregation of extremely likely & somewhat likely against (X axis) the 4 different prices [Cheapest, Cheap, Normal, Expensive]. Final result will look like below:

 

zero99_0-1697635007379.png

 

I have attached the raw sample file and test pbix Link to PBIX & Excel . In the file, there is an existing pie chart (result of this closed thread here. and the raw table has been unpivoted to accomodate those chart. Would appreciate some help on this.

 

 

 

 

 

 

1 ACCEPTED SOLUTION
dk_dk
Super User
Super User

Hi @zero99 

I only worked with the 4 price columns but I think you can replicate the same with the additional columns you have in your data:

1 - Unpivot the 4 Price columns into Attribute - Value pairs:

dk_dk_0-1697638273567.png

2 - Group by (you would need to add grouping for your other columns here, I think). You could also in theory skip the grouping and use COUNTROWS() in the DAX below instead of SUM(Count) column.

dk_dk_1-1697638302302.png

Create two measures:

ExtremelyLikely = CALCULATE(SUM(Data[Count]),Data[Value]="Extremely Likely")/SUM(Data[Count])
ExtremelySomewhatLikely = CALCULATE(SUM(Data[Count]),Data[Value] IN {"Extremely Likely", "Somewhat Likely"})/SUM(Data[Count])

Format them as %, and then configure your visual:

dk_dk_2-1697638484448.png


Additionally, you will want to custom sort the Price categories so the chart is in the right order. You can refer to this thread to do that. 

Hope this helps, let me know if you have any issues!


 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
zero99
Frequent Visitor

Hi @dk_dk 

 

Thank you for your help. I decided to use COUNTROWS() as you mentioned and they worked well for my case. However, as a result of another unpivot for the line chart, the figure in the pie chart is inflated significantly. I have made a new thread HERE  regarding this

dk_dk
Super User
Super User

Hi @zero99 

I only worked with the 4 price columns but I think you can replicate the same with the additional columns you have in your data:

1 - Unpivot the 4 Price columns into Attribute - Value pairs:

dk_dk_0-1697638273567.png

2 - Group by (you would need to add grouping for your other columns here, I think). You could also in theory skip the grouping and use COUNTROWS() in the DAX below instead of SUM(Count) column.

dk_dk_1-1697638302302.png

Create two measures:

ExtremelyLikely = CALCULATE(SUM(Data[Count]),Data[Value]="Extremely Likely")/SUM(Data[Count])
ExtremelySomewhatLikely = CALCULATE(SUM(Data[Count]),Data[Value] IN {"Extremely Likely", "Somewhat Likely"})/SUM(Data[Count])

Format them as %, and then configure your visual:

dk_dk_2-1697638484448.png


Additionally, you will want to custom sort the Price categories so the chart is in the right order. You can refer to this thread to do that. 

Hope this helps, let me know if you have any issues!


 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors