Home > Back-end >  Azure Data Factory Calculate Percent Revenue
Azure Data Factory Calculate Percent Revenue

Time:02-14

I need to calculate billing percentage with respect to the total in Azure Data Factory WorkFlow. I used the expression:

Total_amount/sum(Total_amount) 

But it doesn´t work. How could I calculate percentages using aggregate transformation inside a data flow?

enter image description here

CodePudding user response:

Create a data flow with 2 sources. They can both be the same source, in your example. The first stream will have Source->aggregate [sum(total amount)]->Sink (cached). The second stream will have Source->derived column (total amount/lookup from the cached sink above). My example screenshot below does this exact same thing with loan data. This is what my formula in the derived column looks like: loan_amnt / sink1#output().total_amount

enter image description here

CodePudding user response:

You can try using windows transformation in data flow.

Source:

enter image description here

Add a dummy column using derived column transformation and assign a constant value.

enter image description here

Using windows transformation, get the percentage value of the total amount.

enter image description here

enter image description here

Expression in window column:

multiply(divide(toInteger(Total_amount),sum(toInteger(Total_amount))),100)

enter image description here

Preview of windows transformation:

enter image description here

  • Related