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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
saurav_0101
Regular Visitor

Ignoring specific entries for given key column

Hello Experts!!

 

I am not sure how to put this in language. I have a situation, please see the below table:

saurav_0101_1-1656497684675.png

 

 

Item No.StatusPO. No.
A123568Delivered25645785
A127895Cancelled25345281
A127895Delivered25345281
A127895waiting26845815
A125698waiting21892960
A178546Cancelled23524398
A134578Delivered23524398
A134578Cancelled23524398
A178659Cancelled29350885
A178456waiting21047787
A145876Delivered28745655

 

As you can see from the image with various colours, for any given item number, I want to ignore the row which is having status as cancelled (like row number 3 and row number 9) whereas for the same item number and PO number I have a status other than cancelled.

 

If however, I have a cancelled status row which is having a unique item number or PO number, I don't want to ignore them.

So here out of row no. 3 and 4 have the same item no. and PO. number, I want to ignore 3 as row 4 is not cancelled, while 3 is cancelled.

Similarly, I want to ignore row 9 and keep row 8.

 

But I want to keep rows no. 7 and 10 because although they are cancelled, they have a unique Item no. or PO. No.

 

I am looking for some measure/column to do so.

 

I hope I was able to explain. Thanks in advance.

Saurav

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @saurav_0101 ,

 

I think you can try this code to create a [Flag] column by calculated column.

Keep or Ignore = 
VAR _COUNT =
    CALCULATE (
        COUNT ( 'Table'[Item No.] ),
        ALLEXCEPT ( 'Table', 'Table'[Item No.] )
    )
RETURN
    IF ( AND ( _COUNT > 1, 'Table'[Status] = "Cancelled" ), "Ignore", "Keep" )

Result in my sample is as below.

RicoZhou_0-1657013922095.png

Then create a table visual and add this column into filter, select "Keep".

RicoZhou_1-1657013987841.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @saurav_0101 ,

 

I think you can try this code to create a [Flag] column by calculated column.

Keep or Ignore = 
VAR _COUNT =
    CALCULATE (
        COUNT ( 'Table'[Item No.] ),
        ALLEXCEPT ( 'Table', 'Table'[Item No.] )
    )
RETURN
    IF ( AND ( _COUNT > 1, 'Table'[Status] = "Cancelled" ), "Ignore", "Keep" )

Result in my sample is as below.

RicoZhou_0-1657013922095.png

Then create a table visual and add this column into filter, select "Keep".

RicoZhou_1-1657013987841.png

 

Best Regards,
Rico Zhou

 

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

 

 

amitchandak
Super User
Super User

@saurav_0101 , try

 

 

New column =
var _cnt1 = countx(filter(Table, [Item No] = earlier([Item No]) && [Status] = "Cancelled"), [Item No])+0
var _cnt2 = countx(filter(Table, [Item No] = earlier([Item No]) && [Status] <> "Cancelled"), [Item No])+0
result
Switch(True() ,
[Status] <> "Cancelled" , true(),
[Status] = "Cancelled" && _cnt2 = _cnt1 && _cnt1 >0 , false() ,
true() )

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.