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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Measure for Share in Segment

Hi, I have 2 tables - one with sales data and one with product information and segmentation.

 

Salesdata    Product table 
ProIDPeriodCustomerUnits ProIDSegment
1001110111 1001Car
1001210254 1002Bike
1002110322 1003Car
1002310112 1004Bike
1003410115 1005Bus

 

 

I struggle creating a new measure that will calculate the share in a segment like this:

 

   New Measure
ProIDUnitsTotal SegmentShare in Segment
1001658081 %
10023434100 %
1003158019 %

 

I hope you can help.

 

Br Kent

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Please follow the steps below and get expected result.

First, create a relation as the picture1 shown.

picture1picture1
Second, create two calculated columns using the formula below.

Segment1 = RELATED('Product table'[Segment])

total segment = CALCULATE(SUM(Salesdata[Units]),ALLEXCEPT(Salesdata,Salesdata[Segment1]))

picture2picture2

Third, create a new table by clicking "New Table" under Modeling on Home page using the formula below.  

Result =
SUMMARIZE (
    Salesdata,
    Salesdata[ProID],
    "Units", SUM ( Salesdata[Units] ),
    "total segment", MAX ( Salesdata[total segment] )
)


Finally, create a calculated column using the formula to get share in Segment.

Share in Segment = DIVIDE(Result[Units],Result[total segment])

picture3picture3

Another way to get desired result using measure.

share in segment = DIVIDE(SUM(Salesdata[Units]),MAX(Salesdata[total segment]))

picture4picture4
Please download the .pbix file for further analysis.

Best Regards,
Angelia

 

View solution in original post

3 REPLIES 3
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Please follow the steps below and get expected result.

First, create a relation as the picture1 shown.

picture1picture1
Second, create two calculated columns using the formula below.

Segment1 = RELATED('Product table'[Segment])

total segment = CALCULATE(SUM(Salesdata[Units]),ALLEXCEPT(Salesdata,Salesdata[Segment1]))

picture2picture2

Third, create a new table by clicking "New Table" under Modeling on Home page using the formula below.  

Result =
SUMMARIZE (
    Salesdata,
    Salesdata[ProID],
    "Units", SUM ( Salesdata[Units] ),
    "total segment", MAX ( Salesdata[total segment] )
)


Finally, create a calculated column using the formula to get share in Segment.

Share in Segment = DIVIDE(Result[Units],Result[total segment])

picture3picture3

Another way to get desired result using measure.

share in segment = DIVIDE(SUM(Salesdata[Units]),MAX(Salesdata[total segment]))

picture4picture4
Please download the .pbix file for further analysis.

Best Regards,
Angelia

 

Anonymous
Not applicable

Thanks a lot, @v-huizhn-msft.

 

I was hoping that I would be able to calculate everything in one measure in a combination of CALCULATE and FILTERS.

 

I have found out that in the data there is a total line I would be able to use and that would make everything simpler:

Product table:    
ProdIDProductLevelSupplierCategorySegment
1001Category A   
1002Segment B A 
1003ItemBestAB
1004ItemBestAB
1005ItemZoomAB
1006Segment D A 
1007ItemBestAD
1008ItemZoomAD
1009ItemCoolAD
1010ItemZoomAD

 

SalesData avalible  
ProdIDProductLevelPeriodAmount
1001Category A1160
1002Segment B1120
1003Item130
1004Item140
1005Item150
1006Segment D140
1007Item140
1001Category A2110
1002Segment B280
1003Item210
1004Item250
1005Item220
1006Segment D230
1007Item230

 

Decired outcome    
Filter on ITEM on ProductLevel   
ProdIDProductLevelPeriodSalesTotal SegmentShare in Segment
1003Item13012025 %
1004Item14012033 %
1005Item15012042 %
1007Item14040100 %

 

Are you able to help me with this?

Hi @Anonymous,

How can you get Decired outcome from Product table and SalesData avalible? There is one issue in one thread. You'd better mark the first reply as answer because it gets the right outcome based on your original requirement. Then you create a new thread for your new issue. Thanks a lot.

Best Regards,
Angelia

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.