Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Multiply a result for a value in other column

Hello, I really need help to find a dax function that multiplay result for a value in other column and go consecutive...

for example:

A1 = B1

B1 x A2 = B2

B2 x A3 = B3

B3 x A4 = B4

 

 

Please and Thank you!!

4 Replies

  • Jakinta's avatar
    Jakinta
    Solution Sage

    You can try this in new blank query and adjust according to your needs.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtCztLQ0N1aK1UFlG8JFLAwt4GxzExM428wESZehpVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        Type = Table.TransformColumnTypes(Source,{{"Column1", type number}}),
        NewColumn = Table.FromColumns( {Type[Column1], List.RemoveFirstN(List.Accumulate(Type[Column1],{1}, (s,c)=> s &  {List.Reverse(s){0}*c}), 1)}, {"A","B"}),
        FINAL = Table.TransformColumnTypes(NewColumn,{{"A", Percentage.Type}, {"B", Percentage.Type}})
    in
        FINAL

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Jakinta Thank you, how can I use this query as a new measure? 

      I'm using measure for values in A and need the DAX function to figure out values in B

       

      Please and thank you!

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous 


    You cannot do calculation to change the existing column using DAX. You may only add another column C to have the result but you don't have column B without the calculation. So I am pretty sure you can not achieve this with DAX. 

     

     

    Paul Zheng _ Community Support Team
    Best Regards

     

     

     

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    say, you have a column that index each rows, such as 1,2,3....

    B=PRODUTX(FILTER(Table,Table[Index]<=EARLIER(Table[Index])),Table[A])