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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Share in shop where the product is available

Hi All,

 

I try to create a measure to calculate product share in shop where the product is available. Attach sample data with calculations.

Does anybody know the DAX code which will calculate such a thnig?

Newuser13_1-1673362153882.png

 

1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Please find below a solution but I think your result for shop volumn where product is available | product C is wrong since product c is in shop 1,3 and 4. This emans total 3.100 - store 2 volume 300 = 2.800 and not 2.500 🙂

 

Base Data (Table called SampleShop)

Mikelytics_0-1673364062849.png

 

Measure 1

Product Volume = SUM(SampleShop[Volume])

 Measure 2

Shop Volume where Product is available = 
var __Product = SELECTEDVALUE(SampleShop[Product])
var __ShopsWithProduct = 
    CALCULATETABLE(VALUES(SampleShop[Shop]),SampleShop[Product]=__Product)

RETURN
CALCULATE(
    SUMX(
        __ShopsWithProduct,
        CALCULATE([Product Volume])
    ),
    ALL(SampleShop)
)

 

Measure 3

Share in shop where product is available = 
DIVIDE(
    [Product Volume],
    [Shop Volume where Product is available]
)

Result

Mikelytics_1-1673364125922.png

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

2 REPLIES 2
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Please find below a solution but I think your result for shop volumn where product is available | product C is wrong since product c is in shop 1,3 and 4. This emans total 3.100 - store 2 volume 300 = 2.800 and not 2.500 🙂

 

Base Data (Table called SampleShop)

Mikelytics_0-1673364062849.png

 

Measure 1

Product Volume = SUM(SampleShop[Volume])

 Measure 2

Shop Volume where Product is available = 
var __Product = SELECTEDVALUE(SampleShop[Product])
var __ShopsWithProduct = 
    CALCULATETABLE(VALUES(SampleShop[Shop]),SampleShop[Product]=__Product)

RETURN
CALCULATE(
    SUMX(
        __ShopsWithProduct,
        CALCULATE([Product Volume])
    ),
    ALL(SampleShop)
)

 

Measure 3

Share in shop where product is available = 
DIVIDE(
    [Product Volume],
    [Shop Volume where Product is available]
)

Result

Mikelytics_1-1673364125922.png

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
Anonymous
Not applicable

Thank you!! 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.