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
MeloKutman
Frequent Visitor

Combine totals from different sources in one table (keep them separately)

Hi all,

 

I have a set of different SQL databases with data. Each database contains the record of visitors to a house per day, and I am looking at 7 different houses (databases).

*each database keeps the records in a different format and cannot be combined*  😞

 

I would like to calculate the totals visitors per house and then put all the totals in just one table where the records will be:

House 1 , #visitors

House 2, #visitors

 

My goal is to use a single bar chart for display.

 

I´ve been fighting with DAX for a couples of days, but I think the approaches I am using are not following PBI logic.

 

Any help?

 

thanks!

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

do you need to have live connection to the databases or can you import the data?
if you can import the data then  you can definaetely combine the separate databases in PowerQuery

Otherwise you could try with UNION in DAX



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

6 REPLIES 6
Stachu
Community Champion
Community Champion

do you need to have live connection to the databases or can you import the data?
if you can import the data then  you can definaetely combine the separate databases in PowerQuery

Otherwise you could try with UNION in DAX



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Thanks @Stachu



I have tried UNION, and it does the job.

 

As a note: I have created a set of SUMMARIZE tables for each data source to calculate the values that I wanted to compare.

Then I have used UNION to combine all the tables. Tricky part: you need to make sure that the columns are in the same order in each of the tables in order for UNION to work fine.

 

 

Thanks for your reply.

 

I need live connection to the databases. 

 

So, in order to use UNION, should I need to create new tables where I calculate the totals of each database and then use UNION to merge them all together?

 

It sounds good. Thanks

you can also use table expressions to get them into format you want
https://msdn.microsoft.com/en-us/query-bi/dax/union-function-dax

https://docs.microsoft.com/en-us/power-bi/desktop-calculated-tables



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Hi all,

 

I have a set of different SQL databases with data. Each database contains the record of visitors to a house per day, and I am looking at 7 different houses (databases).

*each database keeps the records in a different format and cannot be combined*  😞

 

I would like to calculate the totals visitors per house and then put all the totals in just one table where the records will be:

House 1 , #visitors

House 2, #visitors

 

My goal is to use a single bar chart for display.

 

I´ve been fighting with DAX for a couples of days, but I think the approaches I am using are not following PBI logic.

 

Any help?

 

thanks!

Hi @MeloKutman,

 

First of all your setup is not completly perceptible, if you could add some example of the strutures of the several tables and some sample data would be easier to help you.

 

However looking at your question if you have some common information (date, ID, ...) something on your table that allows you to make a Dimension table to have the information per group you could then add some measures/calculated columns.

 

In thew attach PBIX you can find an option I have a column in each table that identify the house then I created a dimension table with all the house names then made an additional columns using the following syntax:

 

NumberVisits =
SWITCH (
    DimHouses[House];
    "House1"; COUNT ( House1[ID] );
    "House2"; COUNT ( House2[ID] );
    "House3"; COUNT ( House3[ID] )
)

This returns the number of visits:

visit.png

 

This is just an example of what can be done but as said without any full details about your setup is dificult to help you any further.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.