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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lulubrinki
Regular Visitor

Check several rows with same ID

Hi folks,

 

I am quite new to PowerBI and currently wokring on the following topic:

 

I do have messages and message_threads, both are in one table. Messages can be either OUTBOUND (sent by company) or INBOUND (sent by customer). I now want to count the number of active threads, meaning the number of threads where at least one message was sent by the customer.

 

message-idthread-idmessage-type
11OUTBOUND
21OUTBOUND
32OUTBOUND
42INBOUND
52OUTBOUND
63OUTBOUND
73OUTBOUND
83

INBOUND

 

In this Case thread 2 and 3 are active threads (at least one message with type INBOUND). Thread 1 is not active.

 

The outcome I would expect would for example look like the following:

 

message-idthread-idmessage-typeactive
11OUTBOUNDfalse
21OUTBOUNDfalse
32OUTBOUNDtrue
42INBOUNDtrue
52OUTBOUNDtrue
63OUTBOUNDtrue
73OUTBOUNDtrue
83

INBOUND

true

 

Thanks a lot in advance 🙂

 

1 ACCEPTED SOLUTION

@tamerj1 

 

There's no need to use IF here since ISEMPTY is already a logical function. This is the same:

NOT ISEMPTY(
    FILTER(
        CALCULATETABLE(
            T,
            ALLEXCEPT(
                T,
                T[thread-id]
            )
        ),
        T[message-type] = "INBOUND"
    )
)

View solution in original post

5 REPLIES 5
lulubrinki1
New Member

Thank a lot @daXtreme @tamerj1 ,

I have to correct my initial table I posted. 

factMessages

Message-idThread-IDMessageAttrKey
111
2 2
323
424

 

dimMessageAttributes

MessageAttrKeyType...
1OUTBOUND 
2OUTBOUND 
3INBOUND 
4INBOUND 

 

daXtreme
Solution Sage
Solution Sage

// Let the table be T.

[# Active Threads] =
CALCULATE(
    DISTINCTCOUNT( T[thread-id] ),
    DISTINCT( T[thread-id] ),
    T[message-type] = "inbound",
    REMOVEFILTERS( T )
)
tamerj1
Super User
Super User

Hi @lulubrinki 

please try

=
IF (
    ISEMPTY (
        FILTER (
            CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[thread-id] ) ),
            TableName[message-type] = "INBOUND"
        )
    ),
    FALSE,
    TRUE
)

@tamerj1 

 

There's no need to use IF here since ISEMPTY is already a logical function. This is the same:

NOT ISEMPTY(
    FILTER(
        CALCULATETABLE(
            T,
            ALLEXCEPT(
                T,
                T[thread-id]
            )
        ),
        T[message-type] = "INBOUND"
    )
)

@daXtreme 

You are 100% correct. Thank you

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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