Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Measure for Share in Segment

Hi, I have 2 tables - one with sales data and one with product information and segmentation.   Salesdata         Product table   ProID Period Customer Units   ProID Segment 100...
  • v-huizhn-msft's avatar
    8 years ago

    Hi Anonymous,

    Please follow the steps below and get expected result.

    First, create a relation as the picture1 shown.

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

    Segment1 = RELATED('Product table'[Segment])
    
    total segment = CALCULATE(SUM(Salesdata[Units]),ALLEXCEPT(Salesdata,Salesdata[Segment1]))

    picture2

    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])

    picture3

    Another way to get desired result using measure.

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

    picture4
    Please download the .pbix file for further analysis.

    Best Regards,
    Angelia