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
gumattos
New Member

Creating a visualization using two tables with the same criteria but different values on Count

Hello, What I am trying to achieve is to have a visualization that looks like this:

Screenshot_1.png

 

On my table visualization I will insert the Company Column and count the CustomersID so I can know that in 2018 I had that amount of Customers. On the other column I will have the same result but for 2019, so far so good.

 

But what happens is that each year is from a different table,  and the Customer ID that I had on 2018 might not be on 2019 anymore, if he/she cancelled the service. The same way I have Customers in 2019 that didn't exist in 2018, that means that not all Customers ID exists on both tables.

 

I created a 1:1 relationship using CustomerID so I could relate the tables. But when I create the visualization like the image above, the results from one of the Count columns shows the wrong values. If I use the 'Company' column from 2018 the 2019 column shows the wrong, when the 'Company' column is from 2019, the 2018 count column shows the wrong values.

 

In my understanding that happens because when I use the column 'Company' from 2019, PowerBI will only use the Customer IDs that belongs to the 2019 table, so 2018 table will have IDs missing.

 

When I do DISTINCTCOUNT('2019'[CustomersID]) - DISTINCTCOUNT('2018'[CustomersID]) and try to show the result on the visualization like the image below, the same problem will happen.

 

How can I get around that problem? Thanks in advance for all the help!

 

(The image above shows what I wanted, the subtraction of the results)

Screenshot_2.png

1 REPLY 1
amitchandak
Super User
Super User

If two tables have the same structure the append them.

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

Before that add date column as year start or end date. If you do not have one.

 

Else create a common company and customer dim

company = distinct(union(all(T2018[company),all(T2019[company))

Join it with both the tables.

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.