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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Calvin69
Helper III
Helper III

Flag Rows per Multiple Conditions

Hi all,

 

I have the following sample data which I am tryinng to use in order to created a new column that would flag when a tenant remains or departes.

Expected Column is what I am after:

EntryNoDatePropertyN InclusiveBuildingN InclusiveTitleTenantN InclusiveBreakEnd DabefrecAfterTES_Title_First EntryAfter2RetExpected
17329/04/2021 12:34Property ABuilding AUnit CClient1 31/12/2019 00:0000111  
17329/04/2021 13:30Property ABuilding AUnit CClient1 31/12/2021 00:0000000 Remained
17330/04/2021 14:42Property ABuilding AUnit CClient1 31/12/2021 00:0000000  
17309/05/2021 16:45Property ABuilding AUnit CClient112/04/2021 00:0031/12/2021 00:0000000  
17309/05/2021 17:45Property ABuilding AUnit CClient102/05/2021 00:0031/12/2021 00:0000000  
17321/05/2021 13:44Property ABuilding AUnit CClient102/05/2021 00:0031/12/2021 00:0010000  
17321/05/2021 13:44Property ABuilding AUnit CClient1 31/12/2021 00:0001000RemainedRemained
17321/05/2021 15:12Property ABuilding AUnit CVacant 31/12/2021 00:0000100LeftLeft
17322/05/2021 11:41Property ABuilding AUnit CVacant 31/12/2021 00:0000000  
17323/05/2021 19:43Property ABuilding AUnit CVacant 31/12/2021 00:0000000  
17323/05/2021 19:43Property ABuilding AUnit CVacant 31/12/2021 00:0000000  
17323/05/2021 19:43Property ABuilding AUnit CVacant 31/12/2021 00:0000000  
17324/05/2021 00:56Property ABuilding AUnit CVacant15/09/2021 00:0031/12/2021 00:0000000  
17324/05/2021 01:21Property ABuilding AUnit CVacant30/09/2021 00:0031/12/2021 00:0000000  
17324/05/2021 01:26Property ABuilding AUnit CVacant 31/01/2022 00:0000000  
17324/05/2021 01:38Property ABuilding AUnit CVacant 06/02/2022 00:0010000  
17324/05/2021 01:38Property ABuilding AUnit CVacant 06/02/2022 00:0001000  
17324/05/2021 01:40Property ABuilding AUnit CClient3 06/02/2022 00:0000101  
17323/08/2021 09:53Property ABuilding AUnit CClient3 06/02/2022 00:0000000  
17323/08/2021 09:57Property ABuilding AUnit CClient3 06/02/2022 00:0010000  
17323/08/2021 09:57Property ABuilding AUnit CClient3 06/02/2022 00:0001000Remained

 

Logic:

  • When a client changes to a new one Status should be "Left"
  • When a client is still the same but end date changes to future date, status should be "Remained"
  • When a client is still the same but break changes to future, status should be "Remained"
  • When client = "Vacant" and previous entry was <> "Vacant", status should be "Left"

 

Using the following code and after creating multiple columns "Before/Recent/After" I was able to create column "RET" but still not right, can you please help?

 

 

 

 

 

Ret = 
VAR TenantB = CALCULATE(VALUES('Table'[TenantN Inclusive]), 'Table'[bef] = 1)
VAR TenantC = CALCULATE(VALUES('Table'[TenantN Inclusive]), 'Table'[rec] = 1)

VAR BreakPRe = CALCULATE(VALUES('Table'[Break]), 'Table'[bef] = 1)
VAR BreakCurr = CALCULATE(VALUES('Table'[Break]), 'Table'[rec] = 1)

VAR TenantAA = CALCULATE(VALUES('Table'[TenantN Inclusive]), 'Table'[After] = 1)

VAR IFs = IF(
            'Table'[TenantN Inclusive] = "Vacant - LCR"
            || 'Table'[bef] = 0  &&  'Table'[rec] = 0
            || 'Table'[bef] = 1,
        BLANK(),
        IF( 
            OR(BreakPRe < BreakCurr || TenantB = TenantC,
                BreakCurr = BLANK() && BreakPRe <> BLANK()
                ),
        "False",
        "True"))

VAR GUR = SWITCH(
                TRUE(),
                IFs = "True", "Remained",
                'Table'[After] = 0, BLANK(),
                'Table'[TES_Title_First Entry] = 1, BLANK(),
                TenantC <> TenantAA || TenantC = "Vacant", "Left",
                "Left")

VAR IFY = IF('Table'[After2] = 1, BLANK(), GUR)


Return
IFY

 

 

 

 

 

I am so close...

Thanks

H

2 REPLIES 2
Anonymous
Not applicable

Hi @Calvin69 

What are the values for fields 'Table'[TES_Title_First Entry] and 'Table'[After2] , In the data you provided, I did not find these two fields . Can you provide the values of these two fields ?

 

Best Regards

Community Support Team _ Ailsa Tao

Thanks @Anonymous for looking into this and apologies for the very late reply.

 

I have amended the table data to include missing columns.

 

Thanks in advance.

H

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors