cancel
Showing results for
Did you mean:

## Create credit column from sales table and then calculate percentage between credit and sales

Hi Team,

I have a column in my sales table called Total Sales, the table has a data type of decimal.

This column has postive and negative values, the positive values represent sales numbers, the negative values represent the credit numbers that we send back to customers.

I want to create a column where I can only show the negative values from the total sales column ONLY and then create another column where I can calculate percentage of credit which is basically a division of Credit values over Sales values.

Any help is highly appreciated, thanks a lot

4 REPLIES 4

Thanks @vanessafvg, really appreciate your assistance. Problem is that the credit percentage is not showing proper results unfortunately, your logic makes perfect sense to me. It seems like the variable credit is not showing proper numbers so thats why its throwing the credit percentage off. How I test my numbers is by simply only showing negative values straight from the total sales column found in the sales table and the numbers I get is not matching with the credit variable. Is there an other way we can pull negative values from the total sales column without the use of variables? For instance by using conditions such as If statement?

Super User

percentage of credit =

var credit= calculate(sum(sales), sales < 0)

var sales= calculate(sum(sales), sales > 0)

var result = divide(credit, sales,0)

return result

If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!

Any luck with trying to create this logic using If function please?

Super User

it also depends on what result you want, you might need to convert the credit into an absolute first. (ie postiive number)

percentage of credit =

var credit= calculate(sum(sales), sales < 0)

var sales= calculate(sum(sales), sales > 0)

var result = divide(abs(credit), sales,0)

return result

If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!

Announcements

#### Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

#### Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

#### What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.