Forum Discussion
Pongpon
5 years agoRegular Visitor
Calculate row step like Excel
Hi Community,
I want to calculate data in Power Query like Excel example. I tried many ways but failed.
Value,
Formular,
Thank you.
try this:
// output let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], acc = List.Accumulate( Source[Column1], {null, {}}, (s,c)=>let n=s{0}??List.Sum(Source[Column1]) in {n*2.32+c-n, s{1}&{{c, n, n*2.32, n*2.32+c, n*2.32+c-n}}} ), result = Table.TransformColumns(#table(null, acc{1}), {}, each Number.Round(_, 2)) in result
11 Replies
- ziying35Impactful Individual
try this:
// output let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], acc = List.Accumulate( Source[Column1], {null, {}}, (s,c)=>let n=s{0}??List.Sum(Source[Column1]) in {n*2.32+c-n, s{1}&{{c, n, n*2.32, n*2.32+c, n*2.32+c-n}}} ), result = Table.TransformColumns(#table(null, acc{1}), {}, each Number.Round(_, 2)) in result- PongponRegular Visitor
Thank you.
- wdx223_DanielCommunity Champion
- AnonymousNot applicable
Great, Can you send .pbix file to my email. ([email protected])
Thank you so much. - PongponRegular Visitor
Thank you!
But i put same code in Power Query for Power BI, Not work.
- wdx223_DanielCommunity Champion
your column1 is text, it should be number
- PongponRegular Visitor
I want to add group in data like this,
How to edit code?
Thank you.
- wdx223_DanielCommunity Champion