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
cocomy
Resolver I
Resolver I

Merge queries in different format

Hi

 

I want to merge tables in different format.

I tried query,  naturalleftouterjoin etc but I can not build relationships to work .

When I try to comvert from A to C, duplication occurs. Can you suggest how should I do it to achieve Table E in the end?

 

  • Table A - daily forecast by month by branch
  • Table B- calender (to convert from monthly to daily)
  • Table C = Table A + B , daily forecast by day by branch
  • Table D - actual daily sales by branch *if no sales, no record in the table
  • Table E = Table C+D , actual daily sales by branch with daily forecast

 

2018_02_03_oshietepowerbine.png

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @cocomy,

 

I was abble to replicate your information follow the steps below:

 

  • Create a new table Branchd

   Branch   ID

Tokyo1
Osaka2
Nagoya3

 

  • Related the following tables:
    • Branch - Daily Sales : relate by branch
    • Branch - Daily forecast: relate by branch
    • Calendar - Daily Sales: relate by Date
  • Create the measure below:

 

Measure created on Daily Forecast Table

Daily Forecast Total =
VAR Select_Month =
    MAX ( Calendar[Monthly Date] )
RETURN
    CALCULATE (
        SUM ( 'Daily Forecast'[Daily Forecast] );
        'Daily Forecast'[Monthly Date] = Select_Month
    )


Measure created on Daily Sales Table

Actual totals = SUM('Daily Sales by branch'[Actual])

 

  • Make your table visual with the following columns / measures:
    • Date (Calendar Table)
    • Branch (Branch Table)
    • Actuals totals (measure)
    • Daily Forecast Total (measure)

 

As you can see the result is what you need to have, I have calculated measure because if you need you can calculate differences and percentages over objective.

 

Sales.png

 

Here is a link to PBIX file with the examples and measures.

 

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



View solution in original post

Thank you very much for detailed explanation. It is what I have been looking for ages.

 

All the best,

coco

View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @cocomy,

 

I was abble to replicate your information follow the steps below:

 

  • Create a new table Branchd

   Branch   ID

Tokyo1
Osaka2
Nagoya3

 

  • Related the following tables:
    • Branch - Daily Sales : relate by branch
    • Branch - Daily forecast: relate by branch
    • Calendar - Daily Sales: relate by Date
  • Create the measure below:

 

Measure created on Daily Forecast Table

Daily Forecast Total =
VAR Select_Month =
    MAX ( Calendar[Monthly Date] )
RETURN
    CALCULATE (
        SUM ( 'Daily Forecast'[Daily Forecast] );
        'Daily Forecast'[Monthly Date] = Select_Month
    )


Measure created on Daily Sales Table

Actual totals = SUM('Daily Sales by branch'[Actual])

 

  • Make your table visual with the following columns / measures:
    • Date (Calendar Table)
    • Branch (Branch Table)
    • Actuals totals (measure)
    • Daily Forecast Total (measure)

 

As you can see the result is what you need to have, I have calculated measure because if you need you can calculate differences and percentages over objective.

 

Sales.png

 

Here is a link to PBIX file with the examples and measures.

 

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



Thank you very much for detailed explanation. It is what I have been looking for ages.

 

All the best,

coco

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.