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
Cavring
Helper I
Helper I

Total in a matrix is not considering negative values

Hi

I have a matrix with a range of numbers. The problem is that the total sums up all numbers as if they were were postive.

 

Problem: 2 735 000 + (-3 213 204) = 5 948 204

Should have been: 2 735 000 + (-3 213 204) = -478 204

Power BI 3.pngPower BI 2.png

 

All my number were origianally postive because my dataset wasn't that good. In order to change cost into a negative number, I have made a table with 1's and -1's and I change my values accordingly.

 

To test that my negitive number are actually negative I have:

  • used filters on my values >0 and <0. Both work as they should be
  • sum up cost and revenue seperately, and they both show up as negative and positve (but they already do that in the matrix, so no surprise there)
  • tested how the values look in a collumn chart, and the negative values shows correctly

 

Any help is appreciated

 

Thanks,

Espen

 

 

 

1 ACCEPTED SOLUTION

Thank you @Vvelarde

 

I found a solution with using a collumn (instead of a measure) and the formula:

Beløp med fortegn = if('Kontooversikt'[Fortegn]>0;'Økonomi'[Beløp];-'Økonomi'[Beløp])

 

It worked, so I am happy with that. Thank you for helping though

 

Regards, 

Espen

View solution in original post

11 REPLIES 11
cantoneye
Frequent Visitor

I actually want to achieve the way your problem shows. What I have is the expenses being positive, but still can show Total as Revenue minus Expense (net amount). I think your problem is exactly what I expect. Can you tell me how you achieve that please?

v-yuezhe-msft
Employee
Employee

Hi @Cavring,

In order to provide appropriate method for your sceanrio, could you please share sample data of your original tables and post expected result here? And we will appreciate it if you can post the formulas that you use to calculate Total Sum med fortegn measure.



Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yuezhe-msft.

Thanks for your reply.

This is the result I am after (see bottom matrix in the screen clip):

Power BI matrix.PNG

During the day I have solve the problem, I believe there was a problem with the values being a 'measure'. I turned my values into a new collumn and that solved the problem. 

 

Nevertheless, if you look at the above sreen shot from the incorrect data, there are 4 totals (in bold)

  1. Total 1 is correct
  2. Total 2  1 228 625 is not corret. It sums up negative numbers only and shows as a positive total
  3. Total 3 -678 664 is correct. Negative numbers and a negative totalt
  4. Total 4 is the total ove everything and sums up everything as if they were positve

Eventhough my mesure is not the way to go about this, the above example seems very inconsistent.

Hi @Cavring,


You add date columns to the Matrix visual and the totals are not correct. How do you store the data in your original table? And what do you mean by "I turned my values into a new collumn" ?

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yuezhe-msft

I didn't have and dates in the original matrix, but it was arranged by a year collumn.

 

Sorry for not being clear. What I did was I changed my values:

  • from a measure using a 'Sum' formula
  • to a colloumn using an 'IF' formula creating unique positive and negative values
    • with these values I could make new measures to find the total sum
    • these totals are handeled correctly in a matrix. Both postive and negative values

Thanks for helping,

Espen

Hi @Cavring,

Could you please post sample data of your original tables and formulas you use to calculate column/measures?

According to your description and based on the data in your screenshot, I am not able to reproduce your issue. I create a table using the following data, when I create a Matrix visual, everything works well. We need to know your formulas and original data to provide detailed troubleshoot steps.
2.PNG

1.PNG

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 Hi @v-yuezhe-msft

Here's my data:

https://onlineproinvenia-my.sharepoint.com/personal/espen_skyberg_proinvenia_no/_layouts/15/guestacc...

 

Just so you know I found a solution and cleaned up my formulas. I have made a new measure, but it doesn't reproduce the error 100%.. The total for the whole matrix is still wong though. It doens not sum up correctly.

 

Power BI matrix.PNG

 

 

 

Vvelarde
Community Champion
Community Champion

@Cavring

 

Looking your data the fast solution in this scenario is:

 

TS Total Sum med fortegn =
IF (
    HASONEVALUE ( Kontooversikt[Hovedpost] ),
    [Total Sum] * [Fortegn],
    CALCULATE (
        [Total Sum] * [Fortegn],
        Kontooversikt[Hovedpost] = "0 Variable inntekter"
    )
        + CALCULATE (
            [Total Sum] * [Fortegn],
            Kontooversikt[Hovedpost] = "1 Faste kostnader"
        )
        + CALCULATE (
            [Total Sum] * [Fortegn],
            Kontooversikt[Hovedpost] = "2 Variable kostnader"
        )
        + CALCULATE (
            [Total Sum] * [Fortegn],
            Kontooversikt[Hovedpost] = "3 Finnans inntekter"
        )
)

 

For now you can solve with this, and then with more time to analyze tour data you can optimize this dax.

 




Lima - Peru

Thank you @Vvelarde

 

I found a solution with using a collumn (instead of a measure) and the formula:

Beløp med fortegn = if('Kontooversikt'[Fortegn]>0;'Økonomi'[Beløp];-'Økonomi'[Beløp])

 

It worked, so I am happy with that. Thank you for helping though

 

Regards, 

Espen

Greg_Deckler
Super User
Super User

Is your numeric column based on a measure or a column? If it is measure, technically it is not really summing up your numbers, it is essentially evaluating the measure based upon the context of ALL(). See my post here for a more detailed explanation:

 

http://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/m-p/63376#U63376

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you Smoupre

My values are a measure. Your post explains it, so I played around with some very simple data from Excel to see if it would make any difference but with no luck. 

 

What I am trying to do is to make a table/matrix that shows a company's cost and revenue with the sum at the bottom. Is there an easy way to do that?

 

 

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.