Forum Discussion
Anonymous
5 years agoNot 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 b...
- 5 years ago
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] ) ) ) )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.
Anonymous
5 years agoNot 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
| StopNumber | TripNumber | Billdate | OrderLocationCode | StopActualMiles | Weight1 | DriveTimeHours |
| 49688988 | 77890118886 | 10/3/2020 | 55555 | 0 | 0 | 7.1666 |
| 49688989 | 77890118886 | 10/3/2020 | 55555 | 112 | 9571 | 6.9166 |
| 49688990 | 77890118886 | 10/3/2020 | 55555 | 18 | 15835 | 6.6666 |
| 49688991 | 77890118886 | 10/3/2020 | 55555 | 92 | 0 | 7.75 |
| 49688992 | 77890118887 | 10/3/2020 | 55555 | 0 | 0 | 9.5333 |
| 49688993 | 77890118887 | 10/3/2020 | 55555 | 28 | 8534 | 8.8333 |
| 49688994 | 77890118887 | 10/3/2020 | 55555 | 13 | 5825 | 8.9666 |
| 49688995 | 77890118887 | 10/3/2020 | 55555 | 91 | 2922 | 9.5333 |
| 49688996 | 77890118887 | 10/3/2020 | 55555 | 27 | 5169 | 9.3333 |
| 49688997 | 77890118887 | 10/3/2020 | 55555 | 68 | 0 | 10.1 |
| 49688998 | 77890118888 | 10/3/2020 | 55555 | 0 | 0 | 7.5 |
| 49688999 | 77890118888 | 10/3/2020 | 55555 | 80 | 5711 | 6.45 |
| 49689000 | 77890118888 | 10/3/2020 | 55555 | 106 | 6754 | 7.0833 |
| 49689001 | 77890118888 | 10/3/2020 | 55555 | 17 | 0 | 7.5 |
| 49689002 | 77890118889 | 10/3/2020 | 55555 | 0 | 0 | 5.7666 |
| 49689003 | 77890118889 | 10/3/2020 | 55555 | 67 | 9323 | 5.0666 |
| 49689004 | 77890118889 | 10/3/2020 | 55555 | 28 | 0 | 6.2666 |
| 49689005 | 77890118890 | 10/3/2020 | 55555 | 0 | 0 | 12.8 |
| 49689006 | 77890118890 | 10/3/2020 | 55555 | 111 | 3277 | 12.2 |
| 49689007 | 77890118890 | 10/3/2020 | 55555 | 23 | 7003 | 12.3666 |
| 49689008 | 77890118890 | 10/3/2020 | 55555 | 75 | 5418 | 12.1666 |
| 49689009 | 77890118890 | 10/3/2020 | 55555 | 194 | 0 | 12.9166 |
| 49689010 | 77890118891 | 10/3/2020 | 55555 | 0 | 0 | 8.55 |
| 49689011 | 77890118891 | 10/3/2020 | 55555 | 83 | 5749 | 7.3833 |
| 49689012 | 77890118891 | 10/3/2020 | 55555 | 2 | 6546 | 7.55 |
| 49689013 | 77890118891 | 10/3/2020 | 55555 | 3 | 8635 | 8.65 |
| 49689014 | 77890118891 | 10/3/2020 | 55555 | 89 | 0 | 9.55 |
| OrderLocationCode | Location |
| 55555 | Apple Sales |
v-yingjl
Community Support
5 years agoHi 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] )
)
)
)
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.