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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Aditya_Nayak
Regular Visitor

Share and contribution calculations

Hi Power BI Community, please help me with the calculation logic in Power BI for columns "Share" and "Contribution" in the attached Help.PNGscreenshot. I have mentioned the formula in the relevant cells of the table to make it easier to understand the ask.

 

Thanks in advance! Happy New Year!

- Aditya Nayak

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Aditya_Nayak ,

As all the products are in the same column, they are in the same level in your sample, you cann't directly divide them, here's my solution.

1.Create another table indicating the relationship between the product and its superior product, and make relationship between the two tables.

vkalyjmsft_0-1641460147157.png

vkalyjmsft_1-1641460399037.png

2.Create two measures.

Contribution = 
DIVIDE (
    MAX ( 'Table'[Sales] ),
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Geography] = MAX ( 'Table'[Geography] )
                && 'Table'[Product] = MAX ( 'Table (2)'[Upper level product] )
        ),
        'Table'[Sales]
    )
)
Share = 
IF (
    MAX ( 'Table'[Product] )
        IN { "Manufacture Furniture", "Manufacture Tables", "Manufacture Chairs" },
    [Contribution],
    BLANK ()
)

3.Get the expected result.

vkalyjmsft_2-1641460544853.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @Aditya_Nayak ,

As all the products are in the same column, they are in the same level in your sample, you cann't directly divide them, here's my solution.

1.Create another table indicating the relationship between the product and its superior product, and make relationship between the two tables.

vkalyjmsft_0-1641460147157.png

vkalyjmsft_1-1641460399037.png

2.Create two measures.

Contribution = 
DIVIDE (
    MAX ( 'Table'[Sales] ),
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Geography] = MAX ( 'Table'[Geography] )
                && 'Table'[Product] = MAX ( 'Table (2)'[Upper level product] )
        ),
        'Table'[Sales]
    )
)
Share = 
IF (
    MAX ( 'Table'[Product] )
        IN { "Manufacture Furniture", "Manufacture Tables", "Manufacture Chairs" },
    [Contribution],
    BLANK ()
)

3.Get the expected result.

vkalyjmsft_2-1641460544853.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-yanjiang-msft ,

 

Yes - this worked. Thanks for this solution! 🙂

 

Regards,

Aditya Nayak

Aditya_Nayak
Regular Visitor

Hi @amitchandak ,

 

I've added a few details to clarify the ask. Please refer the attached image. Looking forward to a quick solution.

 

Thanks!Help.PNG

Aditya_Nayak
Regular Visitor

GeographyProductSalesShareContribution
All LocationsTotal Furniture100-100/100
All LocationsManufacturer Furniture6060/10060/100
All LocationsSub-Category Chairs90-90/100
All LocationsManufacturer Chairs4040/9040/90
All LocationsSub-Category Tables70-70/100
All LocationsManufacturer Tables5050/7050/70

@Aditya_Nayak wrote:

Hi Power BI Community, please help me with the calculation logic in Power BI for columns "Share" and "Contribution" in the attached


@Aditya_Nayak wrote:

Hi Power BI Community, please help me with the calculation logic in Power BI for columns "Share" and "Contribution" in the attached Help.PNGscreenshot. I have mentioned the formula in the relevant cells of the table to make it easier to understand the ask.

 

Thanks in advance! Happy New Year!

- Aditya Nayak



screenshot. I have mentioned the formula in the relevant cells of the table to make it easier to understand the ask.

 

Thanks in advance! Happy New Year!

- Aditya Nayak


Thanks @amitchandak ! I tried both the statements that you mentioned, but didn't get the desired results. Please refer the attached table for sample data and sample output. Thanks!

amitchandak
Super User
Super User

@Aditya_Nayak , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Seem like

divide(sum(Table[Sale]), calculate(sum(Table[Sale]),allexcept(Table, Table[geography], Table[Product]))

 

or

 

divide(sum(Table[Sale]), calculate(sum(Table[Sale]),filter(allselected(Table), Table[geography] = max(Table[geography]) && Table[Product] = max(Table[Product]) ))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.