cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Angela_Rom Regular Visitor
Regular Visitor

How to create query using data from existing tables in Power Query Editor

Hello Everyone,

 

I am trying to create a 12 month view for five groups of data located in five different tables. The issue I am having is that I need the 12 month view to be created in order to tie in all the data to the date which is Month/ Year format.  I was thinking of creating a blank query with Month Range listed as 1-12 and bring in all the data. Below is what I would like the table to look like. I want to arrange the month date by descending order and show only a 12 month view. I think for each column, I must create a formula for each column. What type of formula would I need to create to tie each month with the date range?

 

 

Date Range123456789101112
Month - YearNov-18Oct-18Sep-18Aug-18Jul-18Jun-18May-18Apr-18Mar-18Feb-18Jan-18Nov-17
FRCAST71.5960.5451.3651.3651.3651.3651.3651.3651.3651.3619.3521.41
RECEIPTS000000000000
GROSSUSG911515908474125123106985485
Turn-Ins0400-100-000000600-00
QOH-EOM1732904100841582834065121064

 

 

7 REPLIES 7
Super User
Super User

Re: How to create query using data from existing tables in Power Query Editor

Hi,

 

Create a Calendar table and build a relationship from the Date column of each of the 5 different tables to the Date column of the Calendar Table.  In the Calendar Table, write these calculated column formula to extract Year and Month

 

Year=Year(Calendar[Date])

Month=FORMAT(Calendar[Date],"mmmm")

 

Create another 12 rows by 2 column table with Month names mentioned in range A2:A13 and numbers (in descending order from 12 to 1) in range B2:B13 (This Table is named Month_Order and the column headings are Month and Order).  Create a relationship from the Months column of the Calendar Table to the Month column of this Table.  In the Calendar Table, write this calculated column formula

 

=RELATED(Month_Order[Order])

 

Now click on any cell in the Month column of the Calendar Table and under Sort By column, select Order.

 

Build your Matrix visual by dragging Year and Month from the Calendar Table to the Column headers.  Write measures to get the figures.

 

Hope this helps.

Community Support Team
Community Support Team

Re: How to create query using data from existing tables in Power Query Editor

Hi @Angela_Rom,

 

If I understand your requirement correctly that the table above is your desired output? If it is, more details would be better. 

 

If it is convenient, please share your sample data which could reproduce the scenario such as the five different tables so that we could help further on it.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Angela_Rom Regular Visitor
Regular Visitor

Re: How to create query using data from existing tables in Power Query Editor

Hi Cherry,

 

Yes, the table above is my desired output. Below is the query I created. First, all the five tables were appended into one query using the Frcast data as the starting point. Then I grouped all transactions to produce the values as well as create a conditional column to create the different transactions. 

 

The issue that I encountered by using the Frcast table as the starting point is that if a part number is not in the frcast query then I will not receive any data. I need the format to look like the table above and if there is no value than zero should populate for any of the transactions.  This is when I realized that I need to tie my data using a date table so that data can be shown based on a 12 month view regardless of the value.  Below is the list of the consolidated query with the appended five tables.  Please let me know if you have any questions about the inforrmation. Thank you too for your help.

 

Part #DateTransactionsValue
778812/1/2017Frcast1.25
778812/1/2017Receipts500
778812/1/2017Turn-Ins100-
98563/1/2018Receipts300
98563/1/2018Frcast2
98563/1/2018Receipts600-
45985/1/2018Grossusg700-
45985/1/2018Receipts400
123511/1/2018Receipts300
123511/12018Grossusg150
Angela_Rom Regular Visitor
Regular Visitor

Re: How to create query using data from existing tables in Power Query Editor

Hi Ashish,

 

Would I create the calendar table using Dax or do I create this as a query editor?

 

Thank you too for your response.

 

Regards,

Angela

Super User
Super User

Re: How to create query using data from existing tables in Power Query Editor

Hi,

 

Click on New Table and write this formula

 

Calendar=CALENDER(DATE(2017,1,1),DATE(2018,12,31))

Angela_Rom Regular Visitor
Regular Visitor

Re: How to create query using data from existing tables in Power Query Editor

Hi Ashish,

 

Thank you for your response. I tried the calendar table as suggested but this view is limited to the dates provided in the formula. I need the dates to show a 12 month view at all times and be able to change each month as the months change. I think I have to create this in Power Editor query by establishing a date table in the query and merging the data with the date table. Do you know anyway to create a date table as a query?

Super User
Super User

Re: How to create query using data from existing tables in Power Query Editor

Hi,

 

This only creates the Calendar Table.  What you wan should be written as a DAX expression.  Share more information to get more specific help.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 208 members 2,223 guests
Please welcome our newest community members: