Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Angela_Rom
Helper I
Helper I

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
v-piga-msft
Resident Rockstar
Resident Rockstar

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.

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
Ashish_Mathur
Super User
Super User

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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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

Hi,

 

Click on New Table and write this formula

 

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


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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?

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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.