Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I want to make a multiple countifs statement in DAX.
The dataframe looks like this:
Routing-port TEX invoice (text format) countifs result
XXXX-1 2 TEXT123 1
XXXX-1 1 TEXT123
XXXX-1 2 TEXT124 1
The count should be that each routing port, TEX should be 2 and invoice should be unqiue. Hence, the countifs formula in Excel looks like this:=COUNTIFS(T:T;[@[Routing port/port]];CY:CY;[@[Invoice Numbers]]). I manually filtered TEX= 2.
I made this formula, but that doesn´t work.
Solved! Go to Solution.
Hi, @Spartanos
Is your Routing-port the same value, or a different one? SELECTEDVALUE is placed in Measure. Whether your Routing-port is the same value or a different value, there is a solution.
Routing-port is the same value:
Column:
Count 1 =
IF (
[TEX] = 2,
CALCULATE (
COUNT ( 'Table'[Routing-port] ),
FILTER ( 'Table', [TEX] = 2 && [invoice] = EARLIER ( 'Table'[invoice] ) )
),
BLANK ()
)
Measure:
Measure =
IF (
SELECTEDVALUE ( 'Table'[TEX] ) = 2,
CALCULATE (
COUNT ( 'Table'[Routing-port] ),
FILTER ( 'Table', [TEX] = 2 && [invoice] = SELECTEDVALUE ( 'Table'[invoice] ) )
),
BLANK ()
)
Routing-port is a different value.
Column:
Count 2 =
CALCULATE (
COUNT ( 'Table 2'[Routing-port] ),
FILTER (
'Table 2',
[TEX] = 2
&& [invoice] = EARLIER ( 'Table 2'[invoice] )
&& [Routing-port] = EARLIER ( 'Table 2'[Routing-port] )
)
)
Measure:
Measure2 =
CALCULATE (
COUNT ( 'Table 2'[Routing-port] ),
FILTER (
ALL ( 'Table 2' ),
[TEX] = 2
&& [invoice] = SELECTEDVALUE ( 'Table 2'[invoice] )
&& [Routing-port] = SELECTEDVALUE ( 'Table 2'[Routing-port] )
)
)
I hope you can get the results you want from it.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi:
Can you try this? Table name = Data
Hi,
Many thanks, this works. Is it also possible to make add the routing port as unique value in the formula as well?
Hi:
Yes:
Hi,
Am I correct that I have to put SELECTEDVALUE in this line of code:
var port = Selectedvalue(Data[Routing Port])
Hi, @Spartanos
Is your Routing-port the same value, or a different one? SELECTEDVALUE is placed in Measure. Whether your Routing-port is the same value or a different value, there is a solution.
Routing-port is the same value:
Column:
Count 1 =
IF (
[TEX] = 2,
CALCULATE (
COUNT ( 'Table'[Routing-port] ),
FILTER ( 'Table', [TEX] = 2 && [invoice] = EARLIER ( 'Table'[invoice] ) )
),
BLANK ()
)
Measure:
Measure =
IF (
SELECTEDVALUE ( 'Table'[TEX] ) = 2,
CALCULATE (
COUNT ( 'Table'[Routing-port] ),
FILTER ( 'Table', [TEX] = 2 && [invoice] = SELECTEDVALUE ( 'Table'[invoice] ) )
),
BLANK ()
)
Routing-port is a different value.
Column:
Count 2 =
CALCULATE (
COUNT ( 'Table 2'[Routing-port] ),
FILTER (
'Table 2',
[TEX] = 2
&& [invoice] = EARLIER ( 'Table 2'[invoice] )
&& [Routing-port] = EARLIER ( 'Table 2'[Routing-port] )
)
)
Measure:
Measure2 =
CALCULATE (
COUNT ( 'Table 2'[Routing-port] ),
FILTER (
ALL ( 'Table 2' ),
[TEX] = 2
&& [invoice] = SELECTEDVALUE ( 'Table 2'[invoice] )
&& [Routing-port] = SELECTEDVALUE ( 'Table 2'[Routing-port] )
)
)
I hope you can get the results you want from it.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |