I have a contract table, with amendment, type and stats columns. But the table source lists the contract and all amendments as a separate row.
I need to categorize contracts by their type and status, based only on the last stats, i mean, based on the highest amendment.
A pivot table return strange results.
My table sample:
contract Type amendment stats
contract 4 service 0 active
contract 1 rent 0 expired
contract 3 lending 2 expired
contract 1 rent 2 active
contract 1 rent 1 active
contract 3 lending 1 expired
contract 2 service 2 revoked
contract 4 service 1 active
contract 3 lending 0 expired
contract 2 service 0 expired
contract 3 lending 3 expired
contract 2 service 1 expired
contract 1 rent 3 expired
A pivot data counting distinct contracts:
And when i double clicked in services field:
A contract can't be 2 stats at same time, the last stats (based on highest amendment) is the unique valid to count. "Contract 2" is considered as "revoked" and expired in this pivot table.
How can I do this? I can't use the "remove duplicates" feature because can't delete any rows from the table.
Edit:
The expected output is:
In this image, each contract was counted only once in each type and stats.
It doesn't necessarily have to be a pivot table, if it's possible to do this using only formulas, that's also valid.
This can also be accomplished using Power Query, available in Windows Excel 2010+ and Microsoft 365 (Windows or Mac)
To use Power Query
Data => Get&Transform => from Table/Range
Home => Advanced Editor
Applied Steps
to understand the algorithmAfter running the Power Query
Close and Load To
PivotTable Report
Type
to RowsStatus
to ColumnsStatus
to Values (should default to Count)Data

Results after Pivoting

You could also do the entire process in Power Query, although adding the Row Totals and Column Totals is a bit more complex:
Result from PQ alone
