Forum Discussion
DAX/Formula HELP!
- 6 years ago
Anonymous try this measure
Measure 3 = SUMX ( FILTER ( ALL ( Bal[MONTH] ), Bal[MONTH] <= MAX ( Bal[MONTH] ) ), CALCULATE ( SUM ( Bal[ADDITIONAL] ) ) ) + CALCULATE ( SUM ( Bal[BEG INV] ), Bal[MONTH] = 1 )I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
Hi Anonymous ,
Create a new blank query and paste this mcode to create a recursive function:
(_table as table, _month as number, _currentMonth as number, _inventoryValue as number) as number =>
let
Source = Table.SelectRows(_table, each [MONTH] = _month),
BEG_INV = if Source[BEG INV]{0} = null or _month > 1 then 0 else Source[BEG INV]{0},
ADDITIONAL = if Source[ADDITIONAL]{0} = null then 0 else Source[ADDITIONAL]{0},
PredictValue = _inventoryValue + ADDITIONAL + BEG_INV,
Result = if _month < _currentMonth then @fn_PredictValues(_table, _month + 1, _currentMonth, PredictValue) else PredictValue
in
Result
Use this mcode to create your base table:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bcxBCsAgDATAr0jOOSSxse1bxP9/Q7GrSMllWYZNaiUlJhXZaSMbVzL05Rme0Zl8sn98oa8jhzs65gVfyuhp/07Tbpgd9gS7NzAVoB+m0dB+w9YB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [MONTH = _t, #"BEG INV" = _t, ADDITIONAL = _t, #"END INV" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"MONTH", Int64.Type}, {"BEG INV", Int64.Type}, {"ADDITIONAL", Int64.Type}, {"END INV", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each fn_PredictValues(#"Changed Type", 1, [MONTH], 0))
in
#"Added Custom"
or create a custom column like this:
Anonymous try this measure
Measure 3 =
SUMX (
FILTER ( ALL ( Bal[MONTH] ), Bal[MONTH] <= MAX ( Bal[MONTH] ) ),
CALCULATE ( SUM ( Bal[ADDITIONAL] ) )
)
+ CALCULATE ( SUM ( Bal[BEG INV] ), Bal[MONTH] = 1 )
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- Anonymous6 years agoNot applicable
Awesome - thank you so much!