Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
leandross89
Helper II
Helper II

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.


TimestampDeviceIndexSearchedCodeRule_rankCalculated Column
21/03/2024 18:42:00A1219390AOthers 
21/03/2024 18:42:00A1219367AOthersOK
21/03/2024 18:42:00A1219391AOthers 
21/03/2024 18:43:00A1220367AOthersOK
21/03/2024 18:43:00A1220391AOthers 
21/03/2024 18:43:00A1220390AOthers 
21/03/2024 18:44:00A1221367AOthersOK
21/03/2024 18:44:00A1221391AOthers 
21/03/2024 18:44:00A1221390AOthers 
21/03/2024 18:45:00A1222  Rank 
21/03/2024 18:49:00A1223  Others 
21/03/2024 18:53:00A1224  Others 
21/03/2024 22:45:00A132812AOthers 
21/03/2024 22:46:00A132912AOthers 
21/03/2024 22:46:00A1329367AOthers 
21/03/2024 22:47:00A1330367AOthers 
21/03/2024 22:47:00A133012AOthers 
21/03/2024 22:48:00A1331367AOthers 
21/03/2024 22:48:00A133112AOthers 
21/03/2024 22:49:00A1332  Others 
21/03/2024 22:53:00A1333  Others 

 

1 ACCEPTED SOLUTION
Anonymous
Not 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")

vkaiyuemsft_0-1712116976596.png

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.

View solution in original post

4 REPLIES 4
Anonymous
Not 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")

vkaiyuemsft_0-1712116976596.png

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.

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

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. 

post an example so I can help you

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.