Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I have a table and i want to create a mesure to calculate sum by each Cat, if i have the same Esp for each Cat and 2 dates i have to take only the mount of the lastdate
| Cat | Esp | Mount | Date |
| A | 1 | 54 | 05/01/2021 |
| A | 1 | 54 | 01/01/2021 |
| A | 2 | 54 | 01/01/2021 |
| C | 3 | 6 | 01/02/2021 |
The measure have to give me that :
For A = 54 (Esp=1 & Date=05/01/2021)+54 (Esp=2 & Date=01/01/2021)=>108
| Cat | Esp | Mount | Sum (Measure) | Date |
| A | 1 | 54 | 108 | 05/01/2021 |
| A | 1 | 54 | 108 | 01/01/2021 |
| A | 2 | 54 | 108 | 01/01/2021 |
| C | 3 | 6 | 6 | 01/02/2021 |
Thank for your help!
Hi @Anonymous ,
Try the formula as below:
Col_result =
VAR count_ =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
ALL ( 'Table' ),
'Table'[Cat] = EARLIER ( 'Table'[Cat] )
&& 'Table'[Esp] = EARLIER ( 'Table'[Esp] )
)
)
VAR count_cat =
CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Cat] ) )
VAR a =
IF (
count_ = 2,
CALCULATE (
MAX ( 'Table'[Mount] ),
FILTER ( ALL ( 'Table' ), LASTDATE ( 'Table'[Date] ) && count_ = 2 )
),
'Table'[Mount]
)
VAR b =
IF ( count_cat = 1, 0, a )
RETURN
a + b
If the problem is still not resolved, please point it out. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your help but if i have a row for Cat =A and date =01/01/2022 and Esp = 20 the result become 128 and i want to get the result by year like for Cat = A -> colResult =108 for Year =2021 and 20 for year =2022.
ColResult must to be calculated by year , how can i update the query ?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |