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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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 Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors