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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ailievsk1
Regular Visitor

Filtering out consumers from a databse

Hello everyone!

 

I have two databases:

1. in which i have listed all customers with customer code - PBI_Consumer_SEE'[GF_Referral_Code]

2. customer codes which i actually need to see in the report (which also consist in databse #1) - Participants'[Customer Code]

 

How can i match them using filter function?

 

I tried this DAX: 

CALCULATE(COUNT('PBI_Consumer_SEE'[GF_Referral_Code]),ALL('Participants'[Customer Code]))

 

Can you please help me out?

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @ailievsk1 ,

 

If you want a calculated table.

 

Table =
CALCULATETABLE (
    DISTINCT ( 'PBI_Consumer_SEE'[GF_Referral_Code] ),
    FILTER (
        ALL ( 'PBI_Consumer_SEE' ),
        'PBI_Consumer_SEE'[GF_Referral_Code] IN VALUES ( 'Participants'[Customer Code] )
    )
)

 

 

If you want to do some filtering in the table visual. You can use the measure provided by amitchandak and drag it into the visual filter and set it greater than 0.

vcgaomsft_0-1681363976280.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Adamboer
Responsive Resident
Responsive Resident

To match the customer codes from the two databases, you can use the FILTER function in DAX. Here is an example of how to use it: CALCULATE( COUNT('PBI_Consumer_SEE'[GF_Referral_Code]), FILTER( 'PBI_Consumer_SEE', 'PBI_Consumer_SEE'[GF_Referral_Code] IN VALUES('Participants'[Customer Code]) ) )

n this formula, the FILTER function is used to select only the rows in the 'PBI_Consumer_SEE' table where the GF_Referral_Code is included in the list of customer codes in the 'Participants' table. The VALUES function is used to return the distinct list of customer codes from the 'Participants' table. Finally, the COUNT function is used to count the number of matching rows in the 'PBI_Consumer_SEE' table.

You can adjust this formula to fit your specific needs, but using the FILTER function in this way should allow you to match the customer codes from the two databases.

amitchandak
Super User
Super User

@ailievsk1 , Try like

Based on what I got , you need measure like

CALCULATE(COUNT('PBI_Consumer_SEE'[GF_Referral_Code]),Filter( PBI_Consumer_SEE',  PBI_Consumer_SEE'[GF_Referral_Code] in values( 'Participants'[Customer Code])))

 

 

or

 

use https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/

Thanks a lot @amitchandak , in fact, i don't need the result in values, i just need to see the needed customer codes listed in a table. That's why i need the measure. 

 

What should i change instead of "in values"? 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.