Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mattyj2009
Helper II
Helper II

Subtotal Not Calculating Correctly

When doing a subtotal with measure customer counts we are getting an incorrect value.  From the data it is showing we should have a subtotal of 4577 and what the actual subtotal is showing is 4554.  The measure I'm using to get the customer count is:

Customer Counts = CALCULATE(DISTINCTCOUNT(Connections[Account Number]), Connections[End Fractional] = 0)

The data has some account numbers multiple times if they have multiple services.  So I need to pull the total number of account numbers minus duplicates and the "End Fractional" should always be zero.  I've put this data in a table and a matrix and still get the same result.  I would assume it has to do with the formula but I'm not sure what is incorrect about it.

Wrong Subtotal.PNG

 

 

 

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

Hi @mattyj2009

Create a calculated column

Column = CALCULATE(DISTINCTCOUNT(Sheet1[account]),FILTER(ALLEXCEPT(Sheet1,Sheet1[area]),[end]=0))

16.png

Create a measure

discount =
VAR filtered =
    FILTER ( ALLEXCEPT ( Sheet1, Sheet1[area] ), [end] = 0 )
VAR countb =
    CALCULATE ( DISTINCTCOUNT ( Sheet1[account] )filtered )
RETURN
    IF (
        HASONEVALUE ( Sheet1[area] ),
        countb,
        SUMX ( VALUES ( Sheet1[Column] ), [Column] )
    )

17.png

 

Best Regards

Maggie

View solution in original post

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @mattyj2009

Create a calculated column

Column = CALCULATE(DISTINCTCOUNT(Sheet1[account]),FILTER(ALLEXCEPT(Sheet1,Sheet1[area]),[end]=0))

16.png

Create a measure

discount =
VAR filtered =
    FILTER ( ALLEXCEPT ( Sheet1, Sheet1[area] ), [end] = 0 )
VAR countb =
    CALCULATE ( DISTINCTCOUNT ( Sheet1[account] )filtered )
RETURN
    IF (
        HASONEVALUE ( Sheet1[area] ),
        countb,
        SUMX ( VALUES ( Sheet1[Column] ), [Column] )
    )

17.png

 

Best Regards

Maggie

I think this will work if I can figure out the dates.  Inside of my data that I pull from I have a date column.  I have a slicer that we can change the dates on to pull data for that specific date. 

Hi @mattyj2009

Sorry to bother you, would you give some feedback if my solution works for you, if not, what's wrong with it, or is there anything else you need?

 

Best Regards

Maggie

I was able to get it to work with the solution provided.  Thanks!

parry2k
Super User
Super User

Here is similar post for you reference, hope it will help to get you going.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.