cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mohanad-Mustafa
Advocate III
Advocate III

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
Mohanad-Mustafa
Advocate III
Advocate III

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?

vanessafvg
Super User
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?

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!




Helpful resources

Announcements
Microsoft Build 768x460.png

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_carousel_with_text (1).png

Charticulator Design Challenge

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

May UG Leader Call Carousel 768x460.png

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.

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!