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
jh_hog
Frequent Visitor

Splitting a net column into positive and negative numbers in a table

Hi, I have data in the folowing format (which alas I can't change)

 Capture1.PNG


 

 

 

 

 

 

 

 

I would like to be able to get a table visualtion like this in PowerBi:

 

Capture_correct.PNG

 

 In other words if the sum of all of the "Net Total" entries for a job is postiive it will be an "Accrued" amount for that job, and if it is negative it is "Deferred" for that job. 

 

So far I can get the split to work on a line by line basis by using the following measure formulas:

 

Accrued = if(sum(Query1[Net Total]) > 0,sum(Query1[Net Total]),0)

Deferred = if(SUm(Query1[Net Total]) < 0,sum(Query1[Net Total]),0)

 

Resulting in this table:

 

Capture_error.PNG


But here lies the problem, the grand total in the table does not work, and putting the measure into a card doesn't either. I think it is because when working out the grand total it is looking to see if the total of all lines is positive or negative then applying the formula, rather than evaluating the net of each job and then summing up this evaluated net. 

  

It feels like a measure is the way to go because we want to be able to use a slicer to vary the entry date range, but it is not much use if the total does not add up. What am I doing wrong, or is there a better way? Many thanks in advance.

4 REPLIES 4
BhaveshPatel
Community Champion
Community Champion

Hi @jh_hog

 

I have solved the problem using Query Editor. follow the screenshots for the solution.

GroupbyGroupbyConditional column 1Conditional column 1Conditional Column 2Conditional Column 2Load the Query and drag the fields to the canvasLoad the Query and drag the fields to the canvas

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Hi Bhavesh, many thanks, unfortunately that does not quite achieve what I need as I also want the date column to be in the query so I can use a slicer, for example If I select a date range of 1/1/2016 to 6/6/2016 I would expect to see the following:

 

Company NumberJob NumberNet TotalAccruedDeferred
200200001-400-40
200200002-4650-465
   TOTAL:

-505

 

And likewise, if it was 1/1/2016 to 5/5/2016, i would expect to see:

 

Company NumberJob NumberNet TotalAccruedDeferred
200200001-900-90
200200002-4800-480
   TOTAL:-570

.

 

Mike - I tried this too, but unfortunatly it still does not show the correct total.

 

Thanks, James

Hi James,

 

Try this. 

Firstly, I created a conditional column as per the below screenshot.

balance1.PNG

Secondly, I created a conditional column for accrued hide column as per the solution presented in first Reply.

If Net Total is greater than 0 Then Net Total Otherwise 0 . I called this column accrued Hide.

 

Thirdly, I created a conditional column for deferred as per the solution presented in the first Reply.

Deferred = if Net Total is less than 0 Then Net Total otherwise 0

 

Load the Query 

 

Create a new measure balance3.PNG 

 

This will give you the final expected results.

 

balance4.PNG

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.
mmanwaring
Resolver I
Resolver I

Hi

I would make a calculated column for Accrued and Deferred and a measure to sum those columns

Regards

Mike

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.