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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dax Filter 2 tables

Hi,

 

I have 2 related table many to one

Table 1

Name     category

Category 1
BCategory 1
CCategory 2
Category 2
Category 2
Category 3
GCategory 4
HCategory 4
ICategory 5
JCategory 6
KCategory 7
LCategory 8
MCategory 9

 

Table 2

Name     Policy      Category 

WP Category 1
FixedCategory 1
 Category 1
WP Category 1
BFixedCategory 1
BFixedCategory 1
BFixedCategory 1
BFixedCategory 1
CFixedCategory 2
CFixedCategory 2
CFixedCategory 2
CFixedCategory 2
WP Category 2
FixedCategory 2
WP Category 2
WP Category 2
WP Category 2
FixedCategory 2
WP Category 2
WP Category 2
WP Category 3
FixedCategory 3
WP Category 3
WP Category 3
GFixedCategory 4
GFixedCategory 4
GFixedCategory 4
GFixedCategory 4
HFixedCategory 4
HWP Category 4
H Category 4
HWP Category 4
HADERCategory 4

 

 

I got the error message when I use this filter : 

 

 A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

measure = 

var  _Conform = Calculate(Distinctcount(Table1[Name], Table1[Category] IN {"Category 1", "Category 2", "Category 3", "Category 4"} && Filter(Table2, Table2[Policy] <> "WP"))

var  _Total = Calculate(Distinctcount(Table1[Name], Table1[Category] IN {"Category 1", "Category 2", "Category 3", "Category 4"} )
Return Rounddown(_Conform/_Total,2)
 It works If I remove Filter(Table2, Table2[Policy] <> "WP")

 

Could you please advide the solution?

Many thanks in advance.

 

1 ACCEPTED SOLUTION

conform:  COUNTROWS ( FILTER ( a, [has WP] = 0 ) )

non-conform: COUNTROWS ( FILTER ( a, [has WP] > 0 ) )

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

MEASURE =
VAR a =
    ADDCOLUMNS (
        SUMMARIZE ( Table1, [Name] ),
        "has WP"CALCULATE ( COUNTROWS ( Table2 ), Table2[Policy] = "WP" )
    )
RETURN
    ROUNDDOWN (
        DIVIDE ( COUNTROWS ( FILTER ( a, [has WP] = 0 ) )COUNTROWS ( a )0 ),
        2
    )

Anonymous
Not applicable

@lbendlin Hi, Many thanks for your quick reply. The measure works, I would like to sort out the list of Conform and No Conform, could you please advise the measure to count the number of Conform and Non Conform.

If the same Name has FIXED and WP, this Name is not conformed. 

Only the Name without any WP is Conform

 

Thank you again. 

Regards,

Tg

conform:  COUNTROWS ( FILTER ( a, [has WP] = 0 ) )

non-conform: COUNTROWS ( FILTER ( a, [has WP] > 0 ) )

Anonymous
Not applicable

@lbendlin Many thanks for your help!

😀

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.