Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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-id | thread-id | message-type |
1 | 1 | OUTBOUND |
2 | 1 | OUTBOUND |
3 | 2 | OUTBOUND |
4 | 2 | INBOUND |
5 | 2 | OUTBOUND |
6 | 3 | OUTBOUND |
7 | 3 | OUTBOUND |
8 | 3 | 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-id | thread-id | message-type | active |
1 | 1 | OUTBOUND | false |
2 | 1 | OUTBOUND | false |
3 | 2 | OUTBOUND | true |
4 | 2 | INBOUND | true |
5 | 2 | OUTBOUND | true |
6 | 3 | OUTBOUND | true |
7 | 3 | OUTBOUND | true |
8 | 3 | INBOUND | true |
Thanks a lot in advance 🙂
Solved! Go to Solution.
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"
)
)
// Let the table be T.
[# Active Threads] =
CALCULATE(
DISTINCTCOUNT( T[thread-id] ),
DISTINCT( T[thread-id] ),
T[message-type] = "inbound",
REMOVEFILTERS( T )
)
Hi @Anonymous
please try
=
IF (
ISEMPTY (
FILTER (
CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[thread-id] ) ),
TableName[message-type] = "INBOUND"
)
),
FALSE,
TRUE
)
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"
)
)
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
21 | |
11 | |
10 | |
10 | |
8 |