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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RyanS32229
Frequent Visitor

Help with Grouping by account

Hey,

 

Some context: We have a table with contracts, including the Account ID of the contract's account, and a Contract ID. Each Account can have multiple contracts in the table, but not at the same time, i.e. they can start a new contract if they close their old contract.

 

I want to calculate a sum of the amount of each account based on their MOST RECENT contract. We have a field for contract number, so effectively need to:

 

Group by Account ID, showing just the row for the highest contract number of that account.

 

I can then sum the contract amount to find the Amount we have in current contracts.

 

I have been trying this through GROUPBY and SUMMARIZECOLUMNS, but I cannot get either of these to work.

 

All help appreciated.

3 REPLIES 3
v-yuezhe-msft
Employee
Employee

@RyanS32229,

Please share sample data of your table and post expected result here so that we can provide you appropriate DAX.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
shebr
Resolver III
Resolver III

Hi @RyanS32229

 

If you are able to add a flag on your contract table, 1 or 'Active' for current, 0 or 'Expired' for expired, you can then filter for only the Active contracts. You then should just be able to select both columns and see a sum of the contract value.

 

Does that help?

 

Thanks

 

shebr

@shebr True!

 

So I'd need to make a calculated column. Something like

 

IF({Contract number = Max contract number for that Account ID}, 1, 0)

 

Any ideas on how I could design the expression?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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