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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Stock Calculation

Hi everyone, I need your small help. I have two facts tables: -
- One is Current stock report
- One is Min-Max report (how much stock a firm need to maintain per month.

? Need to calculate the current stock in the Min-Max table based on some parameter. 

 

Have taken one small example to understand the data pattern:-

Min-Stock Need to Maintain
ProductSizeColorMin-Stock
A2black, blue25
A3orange12
B2blue21
B3white, yellow34

 

Current Stock
ProductSizeColorCurrentStock
A2black5
A3blue4
A2blue3
A3yellow4
A2yellow5
B3white7
B2organge8
B2blue5
B2black4
B3white2

 

Looking for the result as shown below:

Result
ProductSizeColorMin-StockCurrentStock
A2black, blue258
A3orange120
B2blue215
B3white, yellow349

 

Note:- 
For product A, we need to find the color combination of both black and blue in a single cell. We have 1200 products. Need to write one dax function to fetach the corrent data. We can't bifurcation the color combination to two different row. We are fine with any ratio between black and blue. 
Please anyone knows give me the solutions.
@Ruth,  @amitchandak,  @Tahreem24, @Greg_Deckler, @MFelix, @Pragati11, @mwegener 

@mallot86  @Ruth  @avisingh  @Patrik 

@amitchandak @Tahreem24 @Greg_Deckler @MFelix @Pragati11 @mwegener 

@johnbasha33 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

If you want to write dax to achieve this, you can try to create this measure:

_CurrentStock = 
CALCULATE (
    SUM ( 'Current Stock'[CurrentStock] ),
    FILTER (
        'Current Stock',
        'Current Stock'[Product]
            IN DISTINCT ( 'Min-Stock Need to Maintain'[Product] )
                && 'Current Stock'[Size]
                    IN DISTINCT ( 'Min-Stock Need to Maintain'[Size] )
                        && CONTAINSSTRING (
                            SELECTEDVALUE ( 'Min-Stock Need to Maintain'[Color] ),
                            'Current Stock'[Color]
                        )
    )
) + 0

re.png

Attached the sample file in the below, hopes it could help.

 

Best Regards,
Community Support Team _ Yingjie Li
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

2 REPLIES 2
Anonymous
Not applicable

Thank you @v-yingjl .

v-yingjl
Community Support
Community Support

Hi @Anonymous ,

If you want to write dax to achieve this, you can try to create this measure:

_CurrentStock = 
CALCULATE (
    SUM ( 'Current Stock'[CurrentStock] ),
    FILTER (
        'Current Stock',
        'Current Stock'[Product]
            IN DISTINCT ( 'Min-Stock Need to Maintain'[Product] )
                && 'Current Stock'[Size]
                    IN DISTINCT ( 'Min-Stock Need to Maintain'[Size] )
                        && CONTAINSSTRING (
                            SELECTEDVALUE ( 'Min-Stock Need to Maintain'[Color] ),
                            'Current Stock'[Color]
                        )
    )
) + 0

re.png

Attached the sample file in the below, hopes it could help.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.