How to invoke power query from DAX - excel

I have power query M code that generates the table from JSON input, I am able to load to the DAX using close and apply but I need a way to programmatically load the result set from power query to DAX.
Where can I start?
Edit
Data in power query window:
Using below controls I load the data into DAX (here DAX means load to power pivot data model) or Excel sheet.
Everything looks fine here when I used the Excel/power query controls to load data.
My question here is instead of using Close/Load (Second image) is their any way using code to pull data out of power query.

Related

Excel Power Pivot / Data Model - passing a parameter from worksheet

I have a SQL query I am using for a workbook requiring multiple pivot views from the same dataset. Part of the query is looking at a declared value and based on that value it will either return one result or another, that declared value however needs to be a parameter that end users will input into the workbook.
Normally I would use the excel function to pull the data from the SQL server and then pass a parameter in the advanced query option using " Let Parameters = Excel.CurrentWorkbook()".. however the result set it too large and therefore I need to use Power Pivot.
I however for the life of me can find no help on how to pass a parameter from a cell in a worksheet to power pivot - is this possible, is there a VB script I can use to update the query, alternatively what other options are available other than having to get the end users to go into power pivot and edit the query in the properties each time?
As the variable is used in a computation, I am not using the parameter to filter the dataset and that seems to be the only advice I have been able to find. I am new to Power Pivot.
I came right by doing the following:
Add the SQL query in Power Query, as a data connection only. In the advanced query options, I added the required parameters.
I then selected the query and selected the option to load to Data Model.
Seems to be working.

Why does Power Query not honor the sort in the output table when loaded to the data model?

I'm using Excel 365 and pulling in a table via Power Query. In the underlying SQL, I use an ORDER BY clause to sort the data, which works correctly in the PowerQuery preview and in my SQL client. But I noticed the table that winds up getting loaded in Excel isn't sorted in the same order. I added a sort step to Power Query as the final step, and it still didn't work, even after I wrapped the step in Table.Buffer(). I have also tried it with and without the Preserve column order/sort checkbox checked.
It only honors the sort settings if I uncheck the box to load the query into the data model.
How can I make it follow the sort as specified and load into the data model?

Dynamic date query in Power Query

I'm fairly new to power pivot / query / BI so please excuse my lack of understanding.
Summary of what I'm doing
I have access to an OLAP cube which I am choosing to connect to via Power Pivot Data Model in Excel.
In the Table Import Wizard, I am able to produce what I need from the cube and develop in the Power Model using fixed date ranges. However, this requires me to come back in and alter the date ranges for a number of reasons.
I now want to limit my data dynamically based on a date filter.
I want to do this in the query to limit my model size.
I am working in the "Table Import Wizard" shown below
Snapshot of where I am working, note filter expression
Question:
Am I correct that to achieve this I write an MDX expression? If I add the [Received Date.Day] as a dimension, and change the operator to MDX, it is my understanding I can write an expression to dynamically filter the dataset? When the user refreshes the query they will only get that last 91 days of data based on the received date.
Essentially something like this (excuse my syntax as I have no idea what is required in this platform so I am just relating it to an SQL type syntax):
SELECT Item_Code, Received_Amount
FROM Purchasing_Cube
WHERE Received_Date > = Today()-91
Thanks in advance for any assistance.

Is there a way to export Power Pivot Data Model to Power Query?

I have a power pivot data model of around 20000 rows only and wish to take that data over power query window for further modification. What i'm doing right now is , go to Power Pivot Manage Data Model window and then Copy the data, paste it as normal CSV format and run over power query there. I'm looking forward to an easy way to link between power pivot model and power query, so I could just Refresh All and thereby both models will update without any manual copy/paste work. I have checked all through Google and various websites however all I could find was either copy and paste the data (that I'm doing right now) or a vba (however I couldn't figure out how that works, but it does ideally is a copy paste only to normal spread sheet. Please advice.

How does ETL process map to MS Excel Power Pivot (Data Model)

Moderator please move to appropriate forum if required.
I use MS Excel 2016 for data visualization.
Can understand Extract means saving Excel data onto a spreadsheet and Transforming data means manipulating it in Power Query.
QUESTION:
But if I decide to load data to Power Pivot (Data Model) doesn't that fall back into Transform because you can
Create Calendar Table
Create Measures (or Calculate Columns if necessary)
Or does using Power Pivot (Data Model) fall under Data Modelling because you are no longer formatting, merging pre-existing data;
Rather you are creating new data (i.e. Calendar Table, Measures, etc) to merge with pre-existing data
Kindly clarify
Power Query (now standard excel 2016 in data tab): is an ETL (Extract - Transform - Load) tool. A standard example would be that you would connect it to your source ERP system, and make a product table. That wouldn't be an exact copy of the table, but could consist out of several tables, that are joined. You keep only the relevant columns.
Power Pivot: this is a data modelling tool, it allows you to create relations between data and attribute tables. It gives you the possibility to use time related measures (YTD, Previous Year, ...).
In general when you build your model in power pivot, you can choose to either load the data directly into power pivot (without power query). This is useful if you already have a datawarehouse in which the ETL process is done.
If you have an ETL process to execute, it's better to use power query, and load the data into power pivot. (option: load to data model).

Resources