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
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
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.