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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Create a Calculated column where we can flag the task_id whenever there is a new date

Hello Everyone,

 

I am trying to create a calculated column where the column flags the task_id with 1 if there is a new date or else 0 if the date is repeated. Given below is the Table of what I am trying to build. 

 

Date                    Task_Id            Calculated_Column

01/01/2020          100                             1

01/01/2020          100                             0

01/01/2020          100                             0

25/02/2020          100                             1

25/02/2020          100                             0

25/02/2020          100                             0

15/03/2020          200                             1

15/03/2020          200                             0

15/03/2020          200                             0

08/04/2020          200                             1

08/04/2020          200                             0

 

Please help!

Thanks in advance!

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , You have to add an index in the power query first and then add a new column in DAX

 

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

new column =
if([Index] = minx(filter(Table, [Task_Id] = earlier([Task_Id]) && [date] =earlier([Date])),[Index]) ,1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please correct me if I am wrong.

Because there are some duplicated rows in the table, I created one additional column (Index) in order to differentiate each row and compare one row with the previous row.

 

Picture1.png

 

Then, I created the following Calculated Column.

 

flag task_id =
IF (
newtable[date]
= CALCULATE (
MAX ( newtable[date] ),
FILTER ( newtable, EARLIER ( newtable[Index] ) > newtable[Index] )
),
0,
1
)

 

Please check if it is suitable for your task.

 

Did I answer your question? Mark my post as a solution, this will help others!


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please correct me if I am wrong.

Because there are some duplicated rows in the table, I created one additional column (Index) in order to differentiate each row and compare one row with the previous row.

 

Picture1.png

 

Then, I created the following Calculated Column.

 

flag task_id =
IF (
newtable[date]
= CALCULATE (
MAX ( newtable[date] ),
FILTER ( newtable, EARLIER ( newtable[Index] ) > newtable[Index] )
),
0,
1
)

 

Please check if it is suitable for your task.

 

Did I answer your question? Mark my post as a solution, this will help others!


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

@Jihwan_Kim Thanks for your response, It did work for me!

amitchandak
Super User
Super User

@Anonymous , You have to add an index in the power query first and then add a new column in DAX

 

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

new column =
if([Index] = minx(filter(Table, [Task_Id] = earlier([Task_Id]) && [date] =earlier([Date])),[Index]) ,1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Thanks a lot Amit. It did work for me.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors