Forum Discussion
Anonymous
5 years agoNot applicable
MAT Calculation
Dear Power BI Community, I would like to calculate a MAT using a DAX formula but I would need you help. MAT calculation would be from now (year 2021) over the last 13 periods and would like to calc...
- 5 years ago
Hi Anonymous ,
Sorry, it was an oversight on my part and I have adjusted the relevant measure😋:
Percentage22 = DIVIDE ( (CALCULATE ( COUNTA ( 'rclms_qa'[CONFORMITY] ), FILTER ( ALL(rclms_qa), rclms_qa[Period] = MAX ( rclms_qa[Period] ) && rclms_qa[Year] = MAX ( rclms_qa[Year] ) ) ) - CALCULATE ( COUNTA ( 'rclms_qa'[CONFORMITY] ), FILTER ( ALL(rclms_qa), rclms_qa[Period] = IF ( INT ( VALUE ( RIGHT ( MAX ( rclms_qa[Period] ), 2 ) ) + 1 ) < 10 || INT ( VALUE ( RIGHT ( MAX ( rclms_qa[Period] ), 2 ) ) + 1 ) = 14, "P" & "0" & IF ( INT ( VALUE ( RIGHT ( MAX ( rclms_qa[Period] ), 2 ) ) + 1 ) = 14, 1, INT ( VALUE ( RIGHT ( MAX ( rclms_qa[Period] ), 2 ) ) + 1 ) ), "P" & INT ( VALUE ( RIGHT ( MAX ( rclms_qa[Period] ), 2 ) ) + 1 ) ) && rclms_qa[Year] =IF ( INT ( VALUE ( RIGHT ( MAX ( rclms_qa[Period] ), 2 ))) =13, MAX ( rclms_qa[Year] ), MAX ( rclms_qa[Year] ) - 1) ) )), CALCULATE ( COUNTA ( 'rclms_qa'[CONFORMITY] ), ALL ( 'rclms_qa') ) ) * 100YEARTEST = IF ( INT ( VALUE ( RIGHT ( MAX ( rclms_qa[Period] ), 2 ) ) )=13, MAX ( rclms_qa[Year] ), MAX ( rclms_qa[Year] ) - 1)Best Regards
Lucien
lbendlin
Super User
5 years agoPlease provide sample data in usable format (not as a picture) and show the expected outcome.
Anonymous
5 years agoNot applicable
Hello lbendlin
Here is the table:
| Year | CONFORMITY | Period | Factories |
| 2020 | OK | P13 | RCA |
| 2020 | OK | P13 | RCA |
| 2020 | OK | P13 | RCA |
| 2021 | OK | P01 | RFT |
| 2021 | WRNG_NOK | P01 | RFT |
| 2021 | OK | P02 | RNI |
| 2021 | OK | P02 | RNI |
| 2021 | OK | P02 | RNI |
| 2021 | OK | P02 | RNI |
| 2021 | OK | P02 | RNI |
So the Grade A (control OK) will be calculated based on the formula above - then I need to make the % Grade A difference (P2-P1 2021) + (P1 2021-P13 2020).
Outcome would be + or - x %.
Thanks for your help - and let me know if not clear.
Hervé