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.
Hi there ;
i need your kind support about below issue pls .
i have two table "TableA" and "TableB " as below.TableA is related with orders , and TableB is giving stock quantities that i have for materials. I would like to distrubute stock quantities based on some rules to order quantities .Rules that i want to create like this ;
Also i would like to share with you ready excel tables with below link for your calculation try to make easier.
https://drive.google.com/file/d/10Ju-bzTQo4Dqs1DTdUR_NOHke1UaHaJy/view?usp=sharing
thanks in advance
Solved! Go to Solution.
Hi @erhan_79
I add an index column in Table A to help distribute orders. And add a rule that if the remaining stock of a material is 0, then distribute 0 to the same material in next orders. Here is the PBIX file.
Index = RANKX(TableA,CALCULATE(SUM(TableA[Order Qty]),ALLEXCEPT(TableA,TableA[Order Number])),,ASC,Dense)
Distributed Stock Qty =
VAR _t =
FILTER (
SUMMARIZE (
TableA,
TableA[Order Number],
"MaxOrderDate",
CALCULATE (
MAX ( TableA[Request Date] ),
ALLEXCEPT ( TableA, TableA[Order Number] )
),
"Total Qty", SUM ( TableA[Order Qty] )
),
[MaxOrderDate] <= EOMONTH ( TODAY (), 0 )
)
VAR orders =
SELECTCOLUMNS ( _t, "Order Number", [Order Number] )
RETURN
IF (
NOT ( TableA[Order Number] IN orders ),
0,
VAR _m = TableA[Material]
VAR _i = TableA[Index]
VAR modifiedS =
CALCULATE ( MAX ( TableB[Stock Qty] ), TableB[Material] = _m )
- CALCULATE (
SUM ( TableA[Order Qty] ),
ALLEXCEPT ( TableA, TableA[Material] ),
TableA[Order Number] IN orders,
TableA[Index] < _i
)
VAR modifiedStock =
IF ( modifiedS <= 0, 0, modifiedS )
RETURN
IF ( modifiedStock > TableA[Order Qty], TableA[Order Qty], modifiedStock )
)
Kindly let me know if this helps.
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.
hi dear @v-jingzhang ;
i want a calculated column that mentioned in Table A at the end of right column i want , table B ( stock quantities ) quantities will be distrubuted to Table A . kind of Stock matching llike , but just it has some rules , i will be so grateful if you would help , thanks in advance
Hi @erhan_79 , you want a calculated column in the table or a column shown in a table visual?
hi dear @v-jingzhang ;
i want a calculated column that mentioned in Table A at the end of right column i want , table B ( stock quantities ) quantities will be distrubuted to Table A . kind of Stock matching llike , but just it has some rules , i will be so grateful if you would help
thanks in advance
Hi @erhan_79
I add an index column in Table A to help distribute orders. And add a rule that if the remaining stock of a material is 0, then distribute 0 to the same material in next orders. Here is the PBIX file.
Index = RANKX(TableA,CALCULATE(SUM(TableA[Order Qty]),ALLEXCEPT(TableA,TableA[Order Number])),,ASC,Dense)
Distributed Stock Qty =
VAR _t =
FILTER (
SUMMARIZE (
TableA,
TableA[Order Number],
"MaxOrderDate",
CALCULATE (
MAX ( TableA[Request Date] ),
ALLEXCEPT ( TableA, TableA[Order Number] )
),
"Total Qty", SUM ( TableA[Order Qty] )
),
[MaxOrderDate] <= EOMONTH ( TODAY (), 0 )
)
VAR orders =
SELECTCOLUMNS ( _t, "Order Number", [Order Number] )
RETURN
IF (
NOT ( TableA[Order Number] IN orders ),
0,
VAR _m = TableA[Material]
VAR _i = TableA[Index]
VAR modifiedS =
CALCULATE ( MAX ( TableB[Stock Qty] ), TableB[Material] = _m )
- CALCULATE (
SUM ( TableA[Order Qty] ),
ALLEXCEPT ( TableA, TableA[Material] ),
TableA[Order Number] IN orders,
TableA[Index] < _i
)
VAR modifiedStock =
IF ( modifiedS <= 0, 0, modifiedS )
RETURN
IF ( modifiedStock > TableA[Order Qty], TableA[Order Qty], modifiedStock )
)
Kindly let me know if this helps.
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |