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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

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

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors