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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Itzsridhar
New Member

Sales Return percentage

Hi There,

 

I have a table data which has sales and sales return both in the same sheet, but i have a column named sales type there i have diffrentiated each row as sales or sales return. Now my question is how do i get the sum (returns)/Sum(sales) from this !

 

Thanks in advance !!

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

Hi  @Itzsridhar ,

I created some data:

vyangliumsft_0-1624351993232.png

Here are the steps you can follow:

1. Create calculated column.

Month = MONTH('Sheet1'[Date])

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Sheet1'[Month])
var _sales=
SUMX(FILTER(ALL('Sheet1'),'Sheet1'[sales type]="sales"&&'Sheet1'[Month]=MAX('Sheet1'[Month])),'Sheet1'[Net Value])
var _reurn=
SUMX(FILTER(ALL('Sheet1'),'Sheet1'[sales type]="return"&&'Sheet1'[Month]=MAX('Sheet1'[Month])),'Sheet1'[Net Value])
return
DIVIDE(_reurn,_sales)

3. Result:

The slicer is 1:

vyangliumsft_1-1624351993236.png

 

The slicer is 2:

vyangliumsft_2-1624351993238.png

If I understand something wrong, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data

 

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

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @Itzsridhar ,

I created some data:

vyangliumsft_0-1624351993232.png

Here are the steps you can follow:

1. Create calculated column.

Month = MONTH('Sheet1'[Date])

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Sheet1'[Month])
var _sales=
SUMX(FILTER(ALL('Sheet1'),'Sheet1'[sales type]="sales"&&'Sheet1'[Month]=MAX('Sheet1'[Month])),'Sheet1'[Net Value])
var _reurn=
SUMX(FILTER(ALL('Sheet1'),'Sheet1'[sales type]="return"&&'Sheet1'[Month]=MAX('Sheet1'[Month])),'Sheet1'[Net Value])
return
DIVIDE(_reurn,_sales)

3. Result:

The slicer is 1:

vyangliumsft_1-1624351993236.png

 

The slicer is 2:

vyangliumsft_2-1624351993238.png

If I understand something wrong, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data

 

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.

v-yangliu-msft
Community Support
Community Support

Hi  @Itzsridhar ,

I created some data:

v-yangliu-msft_0-1623317974092.png

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _sales=
SUMX(FILTER(ALL('Sheet1'),'Sheet1'[sales type]="sales"),'Sheet1'[Net Value])
var _reurn=
SUMX(FILTER(ALL('Sheet1'),'Sheet1'[sales type]="return"),'Sheet1'[Net Value])
return
DIVIDE(_reurn,_sales)

2. Result:

v-yangliu-msft_1-1623317974098.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.

@v-yangliu-msft  thanks for sharing your solution, it gives the value for whlole data availalbe in the sheet. when i change the filter along with that this retrun% doesnt change since we have divded the entire value.. i need the return % to be changed based on the filters i make.. 

 

Thanks!

amitchandak
Super User
Super User

@Itzsridhar , Try a measure like

 

divide(calculate(sum(Table[sales]), filter(Table, table[sales type] ="return")), calculate(sum(Table[sales]), filter(Table, table[sales type] ="Sales")))

 

or


divide(calculate(sum(Table[sales]), filter(all(Table), table[sales type] ="return")), calculate(sum(Table[sales]), filter(all(Table), table[sales type] ="Sales")))

Hi @amitchandak  !!

THanks for your reply have tried with your solution, got this error

 

Too many arguments

Itzsridhar_0-1623149620252.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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