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
char23
Helper I
Helper I

Compare and lookup date in same table

Hello, I am trying to add a calculated column to list "deleted" for any ID that does not show in the most recent entry (1). What is the best way to approach this? I tried creating with using if statements, but could not get it to work. I am trying to add the column in green. 

 

IDENTRYDeleted IDs
A2 
B2 
C2Deleted
D2 
A1 
B1 
D1 
1 ACCEPTED SOLUTION

hi @char23 ,

 

try like:

Column =
VAR _entry = [entry]
VAR _id = [id]
VAR _entrypre =_entry - 1
VAR _idlistpre = CALCULATETABLE(VALUES(data[id]), data[entry] = _entrypre, ALL())
VAR _result = IF( _id in _idlistpre || ISEMPTY(_idlistpre) || _entry>2 , BLANK(), "Deleted")
RETURN  _result
 
FreemanZ_0-1721805819922.png

 

View solution in original post

7 REPLIES 7
FreemanZ
Super User
Super User

Hi @char23 ,

 

try to add a column like:

Column = 
VAR _entry = [entry]
VAR _id = [id]
VAR _entrypre =_entry - 1
VAR _idlistpre = CALCULATETABLE(VALUES(data[id]), data[entry] = _entrypre, ALL())
VAR _result = IF( _id in _idlistpre || ISEMPTY(_idlistpre), BLANK(), "Deleted")
RETURN  _result

 

it worked like:

FreemanZ_0-1721707849731.png

 

What if I want to ignore any value in entry column greater than 2. How would I modify? 

IDENTRYDeleted IDs
A3 
B3 
C3 
D3 
A2 
B2 
C2Deleted
D2 
A1 
B1 
D1 

hi @char23 ,

 

try like:

Column =
VAR _entry = [entry]
VAR _id = [id]
VAR _entrypre =_entry - 1
VAR _idlistpre = CALCULATETABLE(VALUES(data[id]), data[entry] = _entrypre, ALL())
VAR _result = IF( _id in _idlistpre || ISEMPTY(_idlistpre) || _entry>2 , BLANK(), "Deleted")
RETURN  _result
 
FreemanZ_0-1721805819922.png

 

Irwan
Memorable Member
Memorable Member

hello @char23 

 

please check if this accomodate your need.

Deleted IDs =
var _ID = 'Table'[ID]
var _Duplicate = COUNTROWS(FILTER('Table','Table'[ID]=_ID))
Return
IF(
    _Duplicate=1,
    "Deleted",
    ""
)

Irwan_0-1721707097095.png

 

The idea is you want to look for duplicate. If no duplicate (count value is 1), then you will have string "Deleted".

 

Hope this will help you.

Thank you.

 

What if I have more than two values in my entry column and want to ingnore anything greater than 2. How would I modify? 

IDENTRYDeleted IDs
A3 
B3 
C3 
D3 
A2 
B2 
C2Deleted
D2 
A1 
B1 
D1 
Irwan
Memorable Member
Memorable Member

hello @char23 

 

modify the conditional if statement should do.

Deleted IDs =
var _ID = 'Table 2'[ID]
var _Duplicate = COUNTROWS(FILTER('Table','Table'[ID]=_ID))
Return
IF(
    _Duplicate=1&&'Table 2'[ENTRY]<=2,
    "Deleted",
    ""
)

Irwan_0-1721783583017.png

 

Adding 'ENTRY' less than or equal 2 in if statement.


Hope this will help you.

Thank you.

Do you use two different tables in this solution? I tried this method, but I am getting deleted by all new IDs where ENTRY = 1. But I want ID C where ENTRY = 2 to show deleted because ID C is not found in the group where ID=1. 

 

IDENTRYDeleted IDs
A3 
B3 
C3 
D3 
E3 
A2 
B2 
C2 
D2 
A1 
B1 
D1 
G1Deleted
H1Deleted

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.