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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-yetao1-msft
Community Support
Community Support

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 @v-yetao1-msft 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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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