cancel
Showing results 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.

Anonymous
Not applicable

## Wrong total column

I have the following visual:

These are the values of MEDIA_PRAZO_MEDIO column:

 1.58177 6.25902 2.27107 3.9435 1.02447 1.4134 0.437936 1.55912 0.03187 1.47557 0.483862 0.532457 0.166125 0.260911 0 0.052677 0.076951

On my visual you can notice that the grand total of this column is 20.736, but if you sum the columns values by hand, you can realize that it's wrong, the real grand total value is 21.57. This is my measure:

```MEDIA_PRAZO_MEDIO =
VAR
VAR
VAR
percentage = _sum / grand_total
RETURN

What can I do to fix it?

8 REPLIES 8
Super User

Hi @Anonymous,

Just simulated your calculation in PBI using you data and your measure and my final resulta was 27.824 (image below) breaking down your formula when you are doing the AVERAGE(DADOS[PRAZO_MED]) you make the average of the value multiplied by the %GT so for row 1 you have = 7 * 22,60% = 1,582 but for the total column you have 27.82 (average of the PRAZO_MED) * 100% = 27.824.

Regards,

MFelix

Regards

Miguel Félix

Proud to be a Super User!

Check out my blog: Power BI em Português

Anonymous
Not applicable

@MFelix, neither 20.73 or  27.82 are corrects, calculate that sum on excel, you will see that the right sum is 21.57. So, what am I doing wrong to calculate my weighted averege?

Super User
Hi @caarlos,

You are refering to different results when you use a measure the calculations is.made based on the context of the visual so if you calculate an average value on a row level the total in the end will also be an average and not a sum.of the previous values, that's why in my print I added the Average calculated on the table and not as a measure. If you want to have the average calculated on the lines but on the tital the sum you need to do it in a different way.

Is the data you show all the lines in your table or are this aggregationa on a larger detail?

If it's your table values you can add the average as a column not a measure and then when you add it to your table it will sum the correct value.

Regards,
MFelix

Regards

Miguel Félix

Proud to be a Super User!

Check out my blog: Power BI em Português

Anonymous
Not applicable

@MFelix, can you exaplain me better what is happening or show me some article about how Power BI calculate the grand total? This is an aggregation of my whole table and you can see this table here. How can I create a measure or a column that the grand total is 21.57?

Helper II

You need to use a SUMX calculation in order to get to the result you are looking for.

I have put a workbook togather with all the calculations you need: https://1drv.ms/u/s!AnKdZAdhTr78dKvMfL9WlrvogE8

Anonymous
Not applicable

@OpenDataLab, thanks it worked. But, I though it would work for my real table. I purposely hid two others columns =(

Look, at my real data here

I have two more columns, one named NATUREZA and other named EMISSAO. The EMISSAO column is a date and the NATUREZA column containg some text values.

On the example that gives 21.57 as a grand total, I have the following filters:

One page filter with NATUREZA ( look at the NATUREZA's values, I've edited it to be easy), just check the string values that contains USE_1, USE_2, USE_3 and USE_4 on the page filter.

And finally I created a slicer with the values of EMISSAO, the values are: Year = 2017, Month = 6 and Days = 1 to 19.

Can you help me to create the right measuere? I've already tried to use ALLEXCEPT, but it did not works....

Thanks.

Employee

Hi @Anonymous,

So what columns do you want to show with the measures on the Table visual on the report, with NATUREZA and EMISSAO column or not? Could you post the expected result against your shared sample data?

Regards

Anonymous
Not applicable

@v-ljerr-msft, currently I have this visual:

On the left side there is a EMISSAO slicer, the values should be between 01/06/2017 and 19/06/2017. And there is page filter using the NATUREZA column, its values that must be checked are USE_1, USE_2, USE_3, USE_4. The only thing that is different of what I want is the sum of MEDIA_PRAZO_MEDIO. The value that I want is 21.56, not 20.74.

Announcements

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

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors