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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gtamir
Post Patron
Post Patron

Getting data from another table to visualization

Hi,

I have a table BestClubZikui 5-20181 which is the customer file, and Sales file.

In the visualization I build a table from the sales table to show the Pharmacy code, Total, Count of visits, and other fields.

I want to add from customers table the number of customers registered in this pharmacy.

This Messuere: No. of customers per Pharmacy = DISTINCTCOUNT('BestClubZikui 5-20181'[CustomerKey])

gives me the same number in all the lines. The relationship is one to many.

If I change the connection to BOTH it gives Blanks for all rows.

I tryed RELATED bu it does not accept it.

How can I put the data from customers in the visualisation?

ScreenHunter_061.jpg

1 ACCEPTED SOLUTION

Hi @gtamir,


It matters in your case because you are joining on CustomerKey which has no matching values between the two tables so the inner join will result in 0 rows. 


I have to say this that please spend sometime on modelling data before you start creating measures and columns. Your main two tables have redundant columns which makes the third person wonder what actually is going on in the model. I would suggest you to remove unwanted columns to make the model clean.

I have solved the problem only keeping in mind that you need to count customers from BestClubZikui 5-20181 table for PharmacyCode in BestClubSales 5-2018.

 

Follow below steps:
1. Create a separate table which contains unique PharmacyCode from BestClubSales 5-2018 table. It can be done by using DAX or Power Query in QueryEditor. Here is the DAX expression for that:

DimPharmacyCode = DISTINCT(VALUES('BestClubSales 5-2018'[PharmacyCode]))

2. Create a relationship between DimPharmacyCode and BestClubZikui 5-20181 on Pharmacy Code column.

3. Use the PharmacyCode column in DimPharmacyCode in your visual table and remove the old one. You will get the desired count.

 

Sending you pbix of the same.

 

Prateek Raina

View solution in original post

16 REPLIES 16

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.