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

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
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.

Top Solution Authors