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
jonclay
Helper IV
Helper IV

Totals not showing correctly in a table

Hi everyone,

I'm certain that a simple solution to my query exists, but I can't seem to figure it out at the moment!

I have a table that holds finance data called all_relevant_transactions. On this table I have several Calculated Fields that work out various totals. An example is shown below:

Total_Rec_201112_Gross =
CALCULATE(
    SUM (all_relevant_transactions[destcodetotal]),
    (all_relevant_transactions[statuscodename]="Paid"),
    DATESBETWEEN(
        all_relevant_transactions[si_transactiondateofpayment],DATE(2011,9,01),DATE(2012,8,31)))

The Calculated Fields themselves are working fine in principle, but I have a problem when showing the Totals in a table. The all_relevant_transactions table contains ALL financial transactions for ALL contacts, and it has a relationship to a Contact table via an N:N relationship that only contains a few of the contacts that exist in the all_relevant_transactions table. So, the all_relevant_transactions table may contain financial transactions for 1000 contacts, but the Contact table may only have 12 contacts in it (this is because it has been filtered down).

So, when I show this data in a table and select the Totals option, it is giving me a total for ALL financial transactions relating to the relevant Calculated Field from the all_relevant_transactions table. The example below shows you what I mean:

jonclay_0-1670493840083.png


What I really need is the total for each column to show the total of all the rows and not the overall total relating to the Calculated Field. I suspect that this is something to do with the way that I've created the Calculated Fields themselves, but I'm unable to work out what I've done wrong!

Any help would be much appreciated.

Many thanks
Jon

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @jonclay ,

 

Totals not showing correctly is a very common thing in Power BI. Maybe you should know ISINSCOPE function and ALL or ALLEXPECT function.

ISINSCOPE function (DAX) - DAX | Microsoft Learn

ALL function (DAX) - DAX | Microsoft Learn

ALLEXCEPT function (DAX) - DAX | Microsoft Learn

 

Since I can't see your data, here's a sample for your reference.

 

You can observe that the totals of the two calculated columns are not the same.

vyadongfmsft_0-1670550997352.png

The DAX formula of the two calculated columns:

% = 
IF (
    ISINSCOPE ( 'Table'[School] ),
    DIVIDE ( [Count], [Total count 2] ),
    DIVIDE ( [Total count 2], CALCULATE ( [Count], ALL ( 'Table' ) ) )
)

% 2 = DIVIDE ( [Count], [Total count 2] )

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yadongf-msft
Community Support
Community Support

Hi @jonclay ,

 

Totals not showing correctly is a very common thing in Power BI. Maybe you should know ISINSCOPE function and ALL or ALLEXPECT function.

ISINSCOPE function (DAX) - DAX | Microsoft Learn

ALL function (DAX) - DAX | Microsoft Learn

ALLEXCEPT function (DAX) - DAX | Microsoft Learn

 

Since I can't see your data, here's a sample for your reference.

 

You can observe that the totals of the two calculated columns are not the same.

vyadongfmsft_0-1670550997352.png

The DAX formula of the two calculated columns:

% = 
IF (
    ISINSCOPE ( 'Table'[School] ),
    DIVIDE ( [Count], [Total count 2] ),
    DIVIDE ( [Total count 2], CALCULATE ( [Count], ALL ( 'Table' ) ) )
)

% 2 = DIVIDE ( [Count], [Total count 2] )

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.