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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors