Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
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 ?
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 49 | |
| 40 | |
| 37 | |
| 14 | |
| 13 |
| User | Count |
|---|---|
| 85 | |
| 70 | |
| 37 | |
| 28 | |
| 27 |