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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Boycie92
Resolver I
Resolver I

New column that identifies two in a row or more

Hi,

 

I am looking for some advice.

 

I have a table that looks like this.

Building

Date

Task

Status

Building 1

Lock Doors

01/01/2020

Done

Building 1

Hover

01/02/2020

Not Done

Building 2

Empty bins

02/01/2020

Not Done

 

I want to add another column to it that will count reoccurring instances. So, if a task has not be done (Not Done) twice or more In a row I want it to say “reoccurring” else I want it to say “not reoccurring”.

 

Does anyone have any suggestions on how to get it into this format using either Power Query or DAX?

 

Thanks,

Boycie92

1 ACCEPTED SOLUTION

Hi @Boycie92 ,

 

Try the following formula:

Column = 
var count_ = 
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table',
            'Table'[Building] = EARLIER('Table'[Building])
            && 'Table'[Task] = EARLIER('Table'[Task])
            && 'Table'[Status] = "Not Done"
        )
    )
return 
    IF(
        count_ >= 2,
        "reoccurring",
        "not reoccurring"
    )

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

6 REPLIES 6
Anonymous
Not applicable

@Boycie92 

 

Can you please supply a representative set of data first of all and show what the data should look like after a column is added with the correct entries?

 

Thanks.

amitchandak
Super User
Super User

@Boycie92 , Try a new column like

new column =
var _cnt= countx(filter(Table, [Building] =earlier([Building]) && [Status] = "Not Done"),[Status])+0
return
if(_cnt >=2, "reoccurring" , "not reoccurring")

 

if needed you can add a similar condition after

[Building] =earlier([Building]) (to reduce scope of partition

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak 

 

Thanks for getting in touch and the help.

 

However it dosn't seem to be working as expected.

 

For example I would expect this to say "not reoccurring" as the last time the task was supposed to have been completed the Status was marked as "Done" any idea why?

 

Boycie92_0-1620288955254.png

 

Thanks,

Boycie92

@Boycie92 , check if this can work

 

new column =
var _cnt= maxx(filter(Table, [Building] =earlier([Building]) ),[Date])
var _max= maxx(filter(Table, [Building] =earlier([Building]) && [Date] =_max),[Status])
return
if([Status] = "not reoccurring", "reoccurring")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak 

 

var _max= maxx(filter(Table, [Building] =earlier([Building]) && [Date] =_max),[Status])

 

it's erroring with the _max "Cannot find name _max"

Hi @Boycie92 ,

 

Try the following formula:

Column = 
var count_ = 
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table',
            'Table'[Building] = EARLIER('Table'[Building])
            && 'Table'[Task] = EARLIER('Table'[Task])
            && 'Table'[Status] = "Not Done"
        )
    )
return 
    IF(
        count_ >= 2,
        "reoccurring",
        "not reoccurring"
    )

image.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.