Forum Discussion
Help to creat a calculated column in dax
Hi dear,
I would like some help to create a calculated column. This calculated column checks if the value in the "Rule_rank" column is "Rank". If so, it verifies if there are previous records where the specified conditions (Searched = 367 and Code = A ) are met. If these conditions are met, it returns "OK"; otherwise, it returns blank.
| Timestamp | Device | Index | Searched | Code | Rule_rank | Calculated Column |
| 21/03/2024 18:42:00 | A1 | 219 | 390 | A | Others | |
| 21/03/2024 18:42:00 | A1 | 219 | 367 | A | Others | OK |
| 21/03/2024 18:42:00 | A1 | 219 | 391 | A | Others | |
| 21/03/2024 18:43:00 | A1 | 220 | 367 | A | Others | OK |
| 21/03/2024 18:43:00 | A1 | 220 | 391 | A | Others | |
| 21/03/2024 18:43:00 | A1 | 220 | 390 | A | Others | |
| 21/03/2024 18:44:00 | A1 | 221 | 367 | A | Others | OK |
| 21/03/2024 18:44:00 | A1 | 221 | 391 | A | Others | |
| 21/03/2024 18:44:00 | A1 | 221 | 390 | A | Others | |
| 21/03/2024 18:45:00 | A1 | 222 | Rank | |||
| 21/03/2024 18:49:00 | A1 | 223 | Others | |||
| 21/03/2024 18:53:00 | A1 | 224 | Others | |||
| 21/03/2024 22:45:00 | A1 | 328 | 12 | A | Others | |
| 21/03/2024 22:46:00 | A1 | 329 | 12 | A | Others | |
| 21/03/2024 22:46:00 | A1 | 329 | 367 | A | Others | |
| 21/03/2024 22:47:00 | A1 | 330 | 367 | A | Others | |
| 21/03/2024 22:47:00 | A1 | 330 | 12 | A | Others | |
| 21/03/2024 22:48:00 | A1 | 331 | 367 | A | Others | |
| 21/03/2024 22:48:00 | A1 | 331 | 12 | A | Others | |
| 21/03/2024 22:49:00 | A1 | 332 | Others | |||
| 21/03/2024 22:53:00 | A1 | 333 | Others |
- Anonymous2 years ago
Hi leandross89 ,
Thanks to Ahmedx for the reply, please allow me to provide another insight:
1. Create a calculated column and populate the data in groups.Column = CALCULATE(MIN('Table'[Index]),FILTER(ALL('Table'),'Table'[Rule_rank] = "Rank" && 'Table'[Index] >= EARLIER('Table'[Index])) )2. Create a calculated column and display OK if it meets the conditions.
Column 2 = IF('Table'[Index] < 'Table'[Column] && 'Table'[Searched] = 367 && 'Table'[Code] = "A" ,"OK")If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- Ahmedx
Super User
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
- leandross89
Helper II
You created a column called flag, and then, used the function fill up to complete with the value 10 the rows that have code A, It doesn´t works in my case because I have others rows in my index above this period presented.
- Ahmedx
Super User
post an example so I can help you
- AnonymousNot applicable
Hi leandross89 ,
Thanks to Ahmedx for the reply, please allow me to provide another insight:
1. Create a calculated column and populate the data in groups.Column = CALCULATE(MIN('Table'[Index]),FILTER(ALL('Table'),'Table'[Rule_rank] = "Rank" && 'Table'[Index] >= EARLIER('Table'[Index])) )2. Create a calculated column and display OK if it meets the conditions.
Column 2 = IF('Table'[Index] < 'Table'[Column] && 'Table'[Searched] = 367 && 'Table'[Code] = "A" ,"OK")If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.