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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
mjgenesis
Frequent Visitor

Group By with filtered calculations

Hello all,  looking for some help with the creation of a table of grouped data from another table.   First I'll provide a sample of the data from the old table (below) and then the formula I'm using to create the new one with the actual and expected results.

 

SortDateCodeProductSalesRepCustomer CodeCustomerTransactionIDTypeTXAmount
202207A10040999999Company137781Purchase14585.2
202207B10040999999Company136169Purchase12329.55
202207C10040999999Company135409Purchase9425.58
202207D10040999999Company138348Purchase8236.62
202207E10040999999Company135716Purchase6818.93
202207F10040999999Company137018Purchase6034.93
202207A10040999999Company138628Purchase5137.25
202207B10040999999Company138193Purchase1587.68
202207C10040999999Company138473Purchase1566.02
202207D10040999999Company136182Purchase1455.24
202207E10040999999Company136509Purchase1427.63
202207F10040999999Company135715Purchase1414.96
202207A10040999999Company137159Purchase1403.72
202207B10040999999Company137156Purchase981.02
202207C10040999999Company137515Purchase963.5
202207D10040999999Company138624Purchase870.86
202207E10040999999Company138347Credit777.74
202207F10040999999Company136721Credit551.62
202207A10040999999Company235403Purchase25000
202207B10040999999Company237961Purchase30000
202207C10040999999Company236386Purchase18000
202207D10040999999Company235719Credit12000
202207E10040999999Company237379Purchase436.79
202207F10040999999Company237964Purchase202.91
202207A10040999999Company236722Purchase140.29
202207B10040999999Company237773Purchase138.61
202207C10040999999Company236040Purchase129.14
202207D10040999999Company236042Purchase115.06
202207E10040999999Company237510Purchase109.84
202207F10040999999Company235890Purchase109.43
202207A10040999999Company238186Purchase99.79
202207B10040999999Company237774Purchase83.45
202207C10040999999Company236501Purchase82.36
202207D10040999999Company238349Purchase80.4
202207E10040999999Company236380Purchase75.79
202207F10040999999Company237960Purchase63.07
202207A10040999999Company236170Purchase49.38
202207B10040999999Company238453Credit45.72
202207C10040999999Company237509Purchase41.85
202207D10040999999Company238451Purchase31.27
202207E10040999999Company237149Purchase30.15
202207F10040999999Company237508Purchase27.62
202207A10040999999Company238626Purchase26.8
202207B10040999999Company238627Purchase24.13
202207C10040999999Company237025Purchase16.23
202207D10040999999Company238185Purchase15.34
202207E10040999999Company235401Credit14.52

 

 

I'm trying to get the grouped total of the transaction amounts but only when the amounts exceeds $10,000, and note how many of those transactions there are.  This should occur for every customer in the old table and there are thousands.  My new table formula is as follows:

 

New_Table =
GROUPBY (
'Old_Table',
'Old_Table'[SortDateCode],
'Old_Table'[Customer],
'Old_Table'[Type],
"Total", SUMx ( CURRENTGROUP (), IF('Old_Table'[TXAmount] > 10000, 'Old_Table'[TXAmount],0)),
"TXCount", COUNTAX ( CURRENTGROUP (), IF('Old_Table'[TXAmount] > 10000,'Old_Table'[TransactionID],0)
))

 

My result is :

 

202207     Company1     Purchase     47     $26914.75

202207     Company2     Purchase     29     $73000.00

202207     Company2     Credit          29     $12000.00

 

I can't seem to figure out how to show the accurate count of 2 instead of 47, 3 instead of 29 (Company 2 Purchase), and 1 instead of 29 (Company 2 Credit).

 

Thank for taking the time to look at this.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @mjgenesis 

please try

New_Table =
SUMMARIZE (
'Old_Table',
'Old_Table'[SortDateCode],
'Old_Table'[Customer],
'Old_Table'[Type],
"Total",
SUMX (
'Old_Table',
IF ( 'Old_Table'[TXAmount] > 10000, 'Old_Table'[TXAmount] )
),
"TXCount",
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
FILTER ( 'Old_Table', 'Old_Table'[TXAmount] > 10000 ),
"@TransactionID", 'Old_Table'[TransactionID]
)
)
)
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @mjgenesis 

please try

New_Table =
SUMMARIZE (
'Old_Table',
'Old_Table'[SortDateCode],
'Old_Table'[Customer],
'Old_Table'[Type],
"Total",
SUMX (
'Old_Table',
IF ( 'Old_Table'[TXAmount] > 10000, 'Old_Table'[TXAmount] )
),
"TXCount",
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
FILTER ( 'Old_Table', 'Old_Table'[TXAmount] > 10000 ),
"@TransactionID", 'Old_Table'[TransactionID]
)
)
)
)

Thanks for this.  It worked.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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