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
Anonymous
Not applicable

Count is Wrong When Field is Removed from Matrix/Table

I have a measure counting the number of months based on business logic, called Total Billable Units.  This measure has been validated and works correctly in a matrix when the fields Name and Loan Number are in the visual.  However, when I remove the Loan Number field, the numbers get inflated and is no longer correct.  I expect the measure to summarize the number of Total Billable Units by Name.  Here is what the measure looks like:

 

Total Billable Units = 
VAR DOT =
    CALCULATE (
        SUMX (
            VALUES ( LoanContracts[LoanNumber] ),
            IF (
                (
                    IF (
                        ISBLANK ( [DOT Received Date] ),
                        MONTH ( TODAY () ),
                        MONTH ( [DOT Received Date] )
                    )
                        - MONTH ( [Funds Released Date] ) - 1
                ) < 0,
                0,
                IF (
                    ISBLANK ( [DOT Received Date] ),
                    MONTH ( TODAY () ),
                    MONTH ( [DOT Received Date] )
                )
                    - MONTH ( [Funds Released Date] ) - 1
            )
        )
    )
VAR Title =
    CALCULATE (
        SUMX (
            VALUES ( LoanContracts[LoanNumber] ),
            IF (
                (
                    IF (
                        ISBLANK ( [Title Received Date] ),
                        MONTH ( TODAY () ),
                        MONTH ( [Title Received Date] )
                    )
                        - MONTH ( [Funds Released Date] ) - 1
                ) < 0,
                0,
                IF (
                    ISBLANK ( [Title Received Date] ),
                    MONTH ( TODAY () ),
                    MONTH ( [Title Received Date] )
                )
                    - MONTH ( [Funds Released Date] ) - 1
            )
        )
    )
RETURN
    DOT + Title

 

Loan Number is from LoanContracts(1:) table and Name is from another table(:M) that shares a 1:M relationship.

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

Hi @Anonymous ,

Do the result data obtained for your measure agree with the data you provided? If so, you can refer to the following:

step1,Import the data you provide:

vluwangmsft_0-1628062389207.png

Since your [Total Billable Units] are actually measures,in my test,totalb2 is measure ,just as  your actual [Total Billable Units]:

totalb2 = MAX(LoanContracts[Total Billable Units])

 

vluwangmsft_1-1628062495575.png

Step 2,

use the below measure:

Measure = SUMX(LoanContracts,[totalb2])

Get as what you want get:

vluwangmsft_3-1628062658204.png

 

 

 

Wish it is helpful for you!

 

Best Regards

Lucien

View solution in original post

5 REPLIES 5
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Do the result data obtained for your measure agree with the data you provided? If so, you can refer to the following:

step1,Import the data you provide:

vluwangmsft_0-1628062389207.png

Since your [Total Billable Units] are actually measures,in my test,totalb2 is measure ,just as  your actual [Total Billable Units]:

totalb2 = MAX(LoanContracts[Total Billable Units])

 

vluwangmsft_1-1628062495575.png

Step 2,

use the below measure:

Measure = SUMX(LoanContracts,[totalb2])

Get as what you want get:

vluwangmsft_3-1628062658204.png

 

 

 

Wish it is helpful for you!

 

Best Regards

Lucien

Greg_Deckler
Super User
Super User

@Anonymous I suspect strongly that you have a measure totals problem. This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

This may also be of use:

Matrix Measure Total Triple Threat Rock & Roll - Microsoft Power BI Community


@ 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...
Anonymous
Not applicable

This seemed very promising but when I tried it out, its still not giving me the right numbers 😞 the numbers are only correct when I have Lender Name and Loan Number in the table.  When I remove Loan Number from the table, the measure is not summing correctly by the Lender Name.

@Anonymous Really difficult to be specific without sample data.


@ 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...
Anonymous
Not applicable

Here's some sample data:

NameLoan NumberFunds Released DateDOT Received DateTitle Received DateTotal Billable Units
ABC01/8/2021 0:002/16/2021 17:51 5
ABC11/11/2021 0:001/20/2021 18:434/6/2021 21:322
ABC21/7/2021 0:001/20/2021 18:444/1/2021 23:172
ABC32/11/2021 0:002/22/2021 17:352/22/2021 17:350
ABC41/20/2021 0:002/8/2021 20:11 5
ABC51/26/2021 0:002/8/2021 20:097/9/2021 16:275
ABC62/11/2021 0:002/22/2021 17:294/13/2021 21:101
ABC72/5/2021 0:002/22/2021 17:155/18/2021 17:222
DE81/19/2021 0:003/5/2021 21:383/5/2021 21:382
DE91/5/2021 0:003/25/2021 19:513/25/2021 19:482
F101/20/2021 0:005/3/2021 17:395/3/2021 17:376
F111/22/2021 0:00 3/2/2021 20:006
F122/23/2021 0:003/2/2021 20:023/2/2021 20:020
F137/21/2021 0:007/23/2021 22:15 0
G141/5/2021 0:002/1/2021 21:362/17/2021 23:300
G151/25/2021 0:003/3/2021 23:595/12/2021 17:564
G163/4/2021 0:003/31/2021 22:184/23/2021 18:180
G172/9/2021 0:003/4/2021 0:153/4/2021 0:150
G183/16/2021 0:005/12/2021 19:105/12/2021 17:582
G195/5/2021 0:006/10/2021 18:327/9/2021 19:031
G206/10/2021 0:007/28/2021 19:117/9/2021 19:010
G216/8/2021 0:006/29/2021 23:267/28/2021 19:310



Essentially, I want a summarized table like this:

 

NameTotal Billable Units
ABC22
DE4
F12
G7

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.