Forum Discussion
Stock on Hand reducing quantity
- 5 years ago
Hi Anonymous ,
You need to create an index column first in power query editor to calculate.
If you do not want the index column load into your table, you can use power query for calculations throughout. The whole query would be like this:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrY0MDU1rXJ3cVXSgXKiolxcDYE8E2NDcyBlaW6hFKtDjEojAwNzIpUampoYKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Finished product" = _t, #"Bill of material" = _t, #"Stock on hand Bill of material" = _t, #"Due to deliverer finished product" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Finished product", type text}, {"Bill of material", type text}, {"Stock on hand Bill of material", Int64.Type}, {"Due to deliverer finished product", Int64.Type}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type), #"Added Custom" = Table.AddColumn(#"Added Index", "Result", each [Stock on hand Bill of material] -List.Sum(List.Range(#"Added Index"[Due to deliverer finished product],0,[Index]))), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"}), #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Result", Int64.Type}}) in #"Changed Type1"If you want to use DAX to calculate, the index column would be kept and you can create a calculated column like this:
Result = [Stock on hand Bill of material] - CALCULATE ( SUM ( 'Table_DAX'[Due to deliverer finished product] ), FILTER ( 'Table_DAX', 'Table_DAX'[Index] <= EARLIER ( 'Table_DAX'[Index] ) ) )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.
Hi Anonymous ,
You need to create an index column first in power query editor to calculate.
If you do not want the index column load into your table, you can use power query for calculations throughout. The whole query would be like this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrY0MDU1rXJ3cVXSgXKiolxcDYE8E2NDcyBlaW6hFKtDjEojAwNzIpUampoYKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Finished product" = _t, #"Bill of material" = _t, #"Stock on hand Bill of material" = _t, #"Due to deliverer finished product" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Finished product", type text}, {"Bill of material", type text}, {"Stock on hand Bill of material", Int64.Type}, {"Due to deliverer finished product", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Result", each [Stock on hand Bill of material] -List.Sum(List.Range(#"Added Index"[Due to deliverer finished product],0,[Index]))),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Result", Int64.Type}})
in
#"Changed Type1"
If you want to use DAX to calculate, the index column would be kept and you can create a calculated column like this:
Result =
[Stock on hand Bill of material]
- CALCULATE (
SUM ( 'Table_DAX'[Due to deliverer finished product] ),
FILTER ( 'Table_DAX', 'Table_DAX'[Index] <= EARLIER ( 'Table_DAX'[Index] ) )
)
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.
- Anonymous5 years agoNot applicable
Thank you, will try and let you know 😃
- PaceNainggolan5 months agoNew Member
Hi v-yingjl,
In the last row, instead of -208 pcs, how can I display the ready OH quantity of 1,332 pcs?