Forum Discussion

robertokzl's avatar
robertokzl
Frequent Visitor
6 years ago
Solved

Union and sum two tables

Hello all, 

I'm try to create a table on Power BI to sum values os 2 different position according company name. 

I create 2 querys, one for Passenger Car and other for Light Comertial Vehicles that i current need separeted

I'm already tryes Merge and Applend but without result i expect! 

For example i would like to sum for each month passanger car and light comertial vehicles by company in just on possition line like sample below but for all companies and name o companies must be all of passenger vehicles + all light comertial vehicles since some companies are present just in one os the queries. 

 

 

Thanks! 

 

 

 

  • Hello @robertokzl -

    First, check out this post on the best details to give when presenting your How-Get-Your-Question-Answer issue-Quickly

    That said, it looks like you need to put your company name (Ford, GM, etc.) and product line (Dodge, Chrysler, etc.) into dimension tables. You can do this outside of PowerBI (depending on where/how your data is stored), or you can dynamically calculate it within PowerBI:

    Company = DISTINCT ( DataTable[Company] )
    
    Product = SUMMARIZE ( DataTable[Company], DataTable[Product] )

    Create the relationships, and then use the Company columns for the visual table instead of the Company value in the data table. This should allow you to display a summary of all your company-wide data.

    If this solution doesn't work for you, review the link above and respond with more details about what you have and what you're trying to do.

    I hope this helps.

    David

2 Replies

  • Icey's avatar
    Icey
    Icon for Community Support rankCommunity Support

    Hi robertokzl ,

     

    What's your data structure like? How does it show in Power BI?

    It's best to create a dummy .pbix file for test. Please remove sensitive information.

    It is suggested to upload your file to OneDrive for Business and then paste the link here.

     

     

    Best Regards,

    Icey

  • dedelman_clng's avatar
    dedelman_clng
    Icon for Community Champion rankCommunity Champion

    Hello @robertokzl -

    First, check out this post on the best details to give when presenting your How-Get-Your-Question-Answer issue-Quickly

    That said, it looks like you need to put your company name (Ford, GM, etc.) and product line (Dodge, Chrysler, etc.) into dimension tables. You can do this outside of PowerBI (depending on where/how your data is stored), or you can dynamically calculate it within PowerBI:

    Company = DISTINCT ( DataTable[Company] )
    
    Product = SUMMARIZE ( DataTable[Company], DataTable[Product] )

    Create the relationships, and then use the Company columns for the visual table instead of the Company value in the data table. This should allow you to display a summary of all your company-wide data.

    If this solution doesn't work for you, review the link above and respond with more details about what you have and what you're trying to do.

    I hope this helps.

    David