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
joshua1990
Post Prodigy
Post Prodigy

Calculated Column with if statement in same table

Hi all!

I have a table that has the following structure:

Order NrGroupKeyTRUE / FALSE
100Group ARTRUE
100Group AZTRUE
100Group BRFALSE
101Group CZTRUE
102Group DRFALSE

 

THere is a column for the Order Nr, Group and Key.

Now I would like to add the last column with TRUE / FALSE based in this requirements:

TRUE if there is any entry for a Order Nr in the same Group and Key = 'Z'.

As you can see above there is Order Nr 100 in the Group A with 2 entries. One with R and one with Z. Therefor all rows for the order 100 in the same group get TRUE. Otherwise FALSE.

 

How is this possible as a calculated column?

1 ACCEPTED SOLUTION

Hi,

Do you mean, Z or W returns true?

Please check the attached pbix file.

 

True False CC =
COUNTROWS (
    FILTER (
        Data,
        Data[Order Nr] = EARLIER ( Data[Order Nr] )
            && Data[Group] = EARLIER ( Data[Group] )
            && OR (
                CONTAINS (
                    FILTER (
                        Data,
                        Data[Order Nr] = EARLIER ( Data[Order Nr] )
                            && Data[Group] = EARLIER ( Data[Group] )
                    ),
                    Data[Key], "Z"
                ),
                CONTAINS (
                    FILTER (
                        Data,
                        Data[Order Nr] = EARLIER ( Data[Order Nr] )
                            && Data[Group] = EARLIER ( Data[Group] )
                    ),
                    Data[Key], "W"
                )
            )
    )
) >= 1

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Untitled.png

 

True False CC = 
COUNTROWS (
    FILTER (
        Data,
        Data[Order Nr] = EARLIER ( Data[Order Nr] )
            && Data[Group] = EARLIER ( Data[Group] )
            && CONTAINS (
                FILTER (
                    Data,
                    Data[Order Nr] = EARLIER ( Data[Order Nr] )
                        && Data[Group] = EARLIER ( Data[Group] )
                ),
                Data[Key], "Z"
            )
    )
) >= 1

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim Awesome, that works perfectly fine! If I want to include another Key into this function like "W", how is this possible?

Hi,

Do you mean, Z or W returns true?

Please check the attached pbix file.

 

True False CC =
COUNTROWS (
    FILTER (
        Data,
        Data[Order Nr] = EARLIER ( Data[Order Nr] )
            && Data[Group] = EARLIER ( Data[Group] )
            && OR (
                CONTAINS (
                    FILTER (
                        Data,
                        Data[Order Nr] = EARLIER ( Data[Order Nr] )
                            && Data[Group] = EARLIER ( Data[Group] )
                    ),
                    Data[Key], "Z"
                ),
                CONTAINS (
                    FILTER (
                        Data,
                        Data[Order Nr] = EARLIER ( Data[Order Nr] )
                            && Data[Group] = EARLIER ( Data[Group] )
                    ),
                    Data[Key], "W"
                )
            )
    )
) >= 1

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.