Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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 ?