cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerBI123456
Post Partisan
Post Partisan

Help with example - filtering for more than 1 dimension

Hi - Appreciate anyone help.

 

Attached is a simple example. I have 2 tables, one is my FACT which has the accounts with codes and the other is my DIM which are the codes. I am trying to do measures to show how many/which accounts have specific codes.

PowerBI123456_0-1633541119376.png

For example, I am calculating the measure below. 

 

Code Measure = CALCULATE([Accounts],and(DIM[Code]="1",'DIM'[Code]="2"))

 

It shows as blank even though I know account A has codes 1 and 2. Pleaese help!

 

PBI File 

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

What about this:

Ch Measure = 
VAR ones = SELECTCOLUMNS(FILTER('FACT', RELATED(DIM[Code]) = "1"), "Account", 'FACT'[Account ])
VAR Twos = SELECTCOLUMNS(FILTER('FACT', RELATED(DIM[Code]) = "2"), "Account", 'FACT'[Account ])
VAR onesAndTwos = INTERSECT(ones, Twos)
RETURN
COUNTROWS(onesAndTwos) 

 

please test at your side.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Code Measure =
VAR newtable =
ADDCOLUMNS (
VALUES ( 'FACT'[Account ] ),
"@one", CALCULATE ( COUNTROWS ( FILTER ( 'FACT', 'FACT'[Code] = "1" ) ) ),
"@two", CALCULATE ( COUNTROWS ( FILTER ( 'FACT', 'FACT'[Code] = "2" ) ) )
)
VAR filternewtable =
FILTER ( newtable, AND ( [@one] <> BLANK (), [@two] <> BLANK () ) )
RETURN
COUNTROWS ( filternewtable )

 

Picture1.png

 


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

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

HotChilli
Super User
Super User

What about this:

Ch Measure = 
VAR ones = SELECTCOLUMNS(FILTER('FACT', RELATED(DIM[Code]) = "1"), "Account", 'FACT'[Account ])
VAR Twos = SELECTCOLUMNS(FILTER('FACT', RELATED(DIM[Code]) = "2"), "Account", 'FACT'[Account ])
VAR onesAndTwos = INTERSECT(ones, Twos)
RETURN
COUNTROWS(onesAndTwos) 

 

please test at your side.

View solution in original post

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors