Forum Discussion
Compound DAX formula. FILTER, MAX and IF
- 3 years ago
Hi angelikakolacz ,
You can try this method:
Add a index column first.
New measure:
Count = CALCULATE ( COUNTROWS ( InvoiceTable ), FILTER ( ALL ( InvoiceTable ), [Account Number] = MAX ( 'InvoiceTable'[Account Number] ) && [Type] = MAX ( 'InvoiceTable'[Type] ) ) )Output = VAR _a = CALCULATE ( MAX ( InvoiceTable[Invoice number] ), FILTER ( ALL ( 'InvoiceTable' ), [Account Number] = MAX ( 'InvoiceTable'[Account Number] ) && [Categoru] = 1 ) ) RETURN IF ( MAX ( 'InvoiceTable'[Invoice number] ) = _a, _a, 0 )The table looks like:
Is this what you expect?
Hope this helps you.
Here is the PBIX file.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
angelikakolacz First create column then measure like below:
Hi Tahreem24 ,
Thank you for your quick respons. I have an other problem.
As result i want to see the MAX of invoice number when the type is the highst. I have add a new column "Count of type". And now i want to see the MAX when the count is the highest (still by account number and only if the category is 1). Can you help me?
See below result:
| Account Number | Invoice number | Type | Categoru | Count of type | Output |
| 100465-8-2020 | 810000004023239 | CM | 1 | 2 | 810000004023239 |
| 100465-8-2020 | 810000004022624 | INV | 1 | 1 | 0 |
| 100465-8-2020 | 810000004022584 | CM | 1 | 2 | 0 |
| 1005268-10-2020 | 810000008661501 | CM | 1 | 1 | 0 |
| 1005268-10-2020 | 810000006602189 | INV | 1 | 2 | 810000006602189 |
| 1005268-10-2020 | 810000006602328 | INV | 1 | 2 | 0 |
| 1005268-11-2020 | 810000008660414 | CM | 1 | 2 | 810000008660414 |
| 1005268-11-2020 | 810000006601178 | CM | 1 | 2 | 0 |
| 1005268-11-2020 | 810000006602429 | INV | 1 | 1 | 0 |
| 1005268-12-2020 | 810000008661358 | CM | 1 | 2 | 810000008661358 |
| 1005268-12-2020 | 810000006601535 | CM | 1 | 2 | 0 |
| 1005268-12-2020 | 810000006601199 | INV | 1 | 1 | 0 |
| 1005601-7-2020 | 810000010994982 | CM | 0 | 3 | 0 |
| 1005601-7-2020 | 810000001536285 | CM | 0 | 3 | 0 |
| 1005601-7-2020 | 810000001317190 | CM | 0 | 3 | 0 |
| 1005601-7-2020 | 810000001131154 | INV | 0 | 1 | 0 |
- v-yinliw-msft3 years ago
Community Support
Hi angelikakolacz ,
You can try this method:
Add a index column first.
New measure:
Count = CALCULATE ( COUNTROWS ( InvoiceTable ), FILTER ( ALL ( InvoiceTable ), [Account Number] = MAX ( 'InvoiceTable'[Account Number] ) && [Type] = MAX ( 'InvoiceTable'[Type] ) ) )Output = VAR _a = CALCULATE ( MAX ( InvoiceTable[Invoice number] ), FILTER ( ALL ( 'InvoiceTable' ), [Account Number] = MAX ( 'InvoiceTable'[Account Number] ) && [Categoru] = 1 ) ) RETURN IF ( MAX ( 'InvoiceTable'[Invoice number] ) = _a, _a, 0 )The table looks like:
Is this what you expect?
Hope this helps you.
Here is the PBIX file.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.