Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
gupta_diksha
Helper II
Helper II

Divide the positive and negative values of a same category

Hi guys,

 

I hope you all are doing fine. 

 

I please need your help in this. I have made a sample table for your reference. 

gupta_diksha_2-1634303467196.png

 

 

So like shown in this table, I have various customers with both positive and negative invoice amounts. Category B has all the positive values and blank represent negative values. I want to calculate the percentage by diving all the positive values of a particular customer by all the negative values of that customer. We can divide these values on the basis of category but I don't know how to do it.

 

Please let me know If you have some other questions regarding the explanation.

 

Thank you very much in advance. 

 

Regards

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @gupta_diksha ,

Here are the steps you can follow:

1. Create calculated column.

flag =
var _positive=
CALCULATE(SUM('Table'[Invoice_amounts]),FILTER(ALL('Table'),'Table'[Category]="B"&&'Table'[Customer name]=EARLIER('Table'[Customer name])))
var _negative=
CALCULATE(SUM('Table'[Invoice_amounts]),FILTER(ALL('Table'),'Table'[Category]=BLANK()&&'Table'[Customer name]=EARLIER('Table'[Customer name])))
return
DIVIDE(_positive,_negative)

2. Result:

vyangliumsft_0-1634524150850.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @gupta_diksha ,

Here are the steps you can follow:

1. Create calculated column.

flag =
var _positive=
CALCULATE(SUM('Table'[Invoice_amounts]),FILTER(ALL('Table'),'Table'[Category]="B"&&'Table'[Customer name]=EARLIER('Table'[Customer name])))
var _negative=
CALCULATE(SUM('Table'[Invoice_amounts]),FILTER(ALL('Table'),'Table'[Category]=BLANK()&&'Table'[Customer name]=EARLIER('Table'[Customer name])))
return
DIVIDE(_positive,_negative)

2. Result:

vyangliumsft_0-1634524150850.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@gupta_diksha , Try a measure like

 


Divide(sumx(filter(Table, Table[Invoice Amount] <0), abs([Invoice Amount])), sumx(filter(Table, Table[Invoice Amount] >0), [Invoice Amount]))

 

or

 

 

averagex(values(Table[Customer Number]), Divide(sumx(filter(Table, Table[Invoice Amount] <0), abs([Invoice Amount])), sumx(filter(Table, Table[Invoice Amount] >0), [Invoice Amount])))

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.