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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
danny_dmv
Frequent Visitor

How to identify if a value exists in rows based on conditions in the same table

Hello experts,

 

I got stuck with this project and can't seem to find a possible solution without creating another table. Basically, I have products in 12M that I need to see if they already exist in the previous years (<>12M). This is what I come up with. Obviously it is not working. Can anyone please take a look and point me to the right direction? Much appreciated!

 

Result = VAR pp = Table[Product] IN ALLSELECTED(FILTER(Table, Table[Time]<>"12M"), Table[Product]) RETURN
IF([Time] = "12M", IF(pp, "Existing", "New"), "")
 
danny_dmv_0-1663269976268.png

 

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

Hi @danny_dmv ,

According to your description, here's my solution.

Create a calculated column.

 

Result =
IF (
    'Table'[Time] = "12M",
    IF (
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[Product] = EARLIER ( 'Table'[Product] )
                    && 'Table'[Time] <> "12M"
            )
        ) > 0,
        "Existing",
        "New"
    )
)

Or if you prefer a measure.

Measure =
IF (
    MAX ( 'Table'[Time] ) = "12M",
    IF (
        COUNTROWS (
            FILTER (
                ALL ( 'Table' ),
                'Table'[Product] = MAX ( 'Table'[Product] )
                    && 'Table'[Time] <> "12M"
            )
        ) > 0,
        "Existing",
        "New"
    )
)

 

Get the correct result.

vkalyjmsft_1-1663298758958.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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
danny_dmv
Frequent Visitor

This works beautifully, thanks so much @v-yanjiang-msft 

v-yanjiang-msft
Community Support
Community Support

Hi @danny_dmv ,

According to your description, here's my solution.

Create a calculated column.

 

Result =
IF (
    'Table'[Time] = "12M",
    IF (
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[Product] = EARLIER ( 'Table'[Product] )
                    && 'Table'[Time] <> "12M"
            )
        ) > 0,
        "Existing",
        "New"
    )
)

Or if you prefer a measure.

Measure =
IF (
    MAX ( 'Table'[Time] ) = "12M",
    IF (
        COUNTROWS (
            FILTER (
                ALL ( 'Table' ),
                'Table'[Product] = MAX ( 'Table'[Product] )
                    && 'Table'[Time] <> "12M"
            )
        ) > 0,
        "Existing",
        "New"
    )
)

 

Get the correct result.

vkalyjmsft_1-1663298758958.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors