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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Power BI Aggregation Tables and Distinct Count a value

Hi,

I am currently setting up my first data model using Power BI Aggregation tables and am having a problem getting distinct count to work with it.  I seem to be able to get sums to work just fine but if I try to distinct count a value and add that to a table with other summed measures it uses a direct query instead of the aggregate tables.  However, if I separate the distinct count from the sums into 2 separate tables then they both hit the aggregate.  So I'm at a loss here.  

 

I am also having problems finding good articles on Power BI Aggregate tables since a lot of the results I get back are 'aggregations' like a group by.  Which isn't what I'm looking for.  

 

 

in manage aggregations i have it setup so the int version of my field is "Count", Points to my fact table, and then the final column is the string version of the column I am counting.  

 

Sorry I'm trying not to post an image since it has table names and such.

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

Based on your description, you can create this calculated table:

New Table =
SUMMARIZE (
    'Table',
    'Table'[StopNumber],
    'Table'[TripNumber],
    'Table'[Billdate],
    'Table'[OrderLocationCode],
    'Table'[Location],
    "Total_Stop",
        CALCULATE (
            SUM ( 'Table'[StopActualMiles] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[TripNumber] = EARLIER ( 'Table'[TripNumber] )
            )
        ),
    "Total_Miles",
        CALCULATE (
            SUM ( 'Table'[Weight1] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[TripNumber] = EARLIER ( 'Table'[TripNumber] )
            )
        ),
    "Total_Drive",
        CALCULATE (
            SUM ( 'Table'[DriveTimeHours] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[TripNumber] = EARLIER ( 'Table'[TripNumber] )
            )
        )
)

re.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
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

6 REPLIES 6
Anonymous
Not applicable

Hi @v-yingjl Mows @amitchandak

Please find the data below

I want to count different stops and trips, but add up the other values

StopNumberTripNumberBilldateOrderLocationCodeStopActualMilesWeight1DriveTimeHours
496889887789011888610/3/202055555007.1666
496889897789011888610/3/20205555511295716.9166
496889907789011888610/3/20205555518158356.6666
496889917789011888610/3/2020555559207.75
496889927789011888710/3/202055555009.5333
496889937789011888710/3/2020555552885348.8333
496889947789011888710/3/2020555551358258.9666
496889957789011888710/3/2020555559129229.5333
496889967789011888710/3/2020555552751699.3333
496889977789011888710/3/20205555568010.1
496889987789011888810/3/202055555007.5
496889997789011888810/3/2020555558057116.45
496890007789011888810/3/20205555510667547.0833
496890017789011888810/3/2020555551707.5
496890027789011888910/3/202055555005.7666
496890037789011888910/3/2020555556793235.0666
496890047789011888910/3/2020555552806.2666
496890057789011889010/3/2020555550012.8
496890067789011889010/3/202055555111327712.2
496890077789011889010/3/20205555523700312.3666
496890087789011889010/3/20205555575541812.1666
496890097789011889010/3/202055555194012.9166
496890107789011889110/3/202055555008.55
496890117789011889110/3/2020555558357497.3833
496890127789011889110/3/202055555265467.55
496890137789011889110/3/202055555386358.65
496890147789011889110/3/2020555558909.55

OrderLocationCodeLocation
55555Apple Sales

Hi @Anonymous ,

Based on your description, you can create this calculated table:

New Table =
SUMMARIZE (
    'Table',
    'Table'[StopNumber],
    'Table'[TripNumber],
    'Table'[Billdate],
    'Table'[OrderLocationCode],
    'Table'[Location],
    "Total_Stop",
        CALCULATE (
            SUM ( 'Table'[StopActualMiles] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[TripNumber] = EARLIER ( 'Table'[TripNumber] )
            )
        ),
    "Total_Miles",
        CALCULATE (
            SUM ( 'Table'[Weight1] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[TripNumber] = EARLIER ( 'Table'[TripNumber] )
            )
        ),
    "Total_Drive",
        CALCULATE (
            SUM ( 'Table'[DriveTimeHours] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[TripNumber] = EARLIER ( 'Table'[TripNumber] )
            )
        )
)

re.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , For distinctcount you have keep unaggregated Table only.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

This may be a stupid question but I am struggling with it.  

How do I join a unaggregated table back to my aggregated ones?  Since if I create one with a distinct count or list of the numbers i'm counting the arrow points in the wrong direction.  From the distinct one back to the agg.  

 

Do I need to have them all connect to the same dims and have them filter that way?

Anonymous
Not applicable

Hi @Anonymous ,

Based on your description, not certain what is your expected output. Could you please consider sharing a dummy sample for further discussion without any fact information?

 

Sample data and expected output would help tremendously.

Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors