1

I have a power query connection to a Tabular data model. I have some MDX that runs and would like to pass a value in the WHERE statement to the MDX from the value of a cell. Any ideas on how to do this? I set the Power Query procedure up before to grab the value of the cell and use that as a filter by pulling it in through a second procedure, but that method does not work when I use that named range in the MDX.

Essentially I have a "... WHERE ( [Table].[ID].&[123] )" and I want to "123" part to be replaced with the value in cell A1 each time I refresh the process.

Any ideas?

1 Answer 1

2

You can combine text values in the Power Query language using the & operator, like "[Table].[ID].&[" & CellValue & "])". If you do use this method you may have to turn off privacy levels, and you should make sure that you either trust the values coming from the cells or properly encode those values by doubling the ] character (you can use Text.Replace(CellValue, "]", "]]") to do this).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! So if the cell I want to use as the value is on "Sheet1" and cell B2, how would that look?
Depends on the query name. You can use "From Table" in the ribbon to get the value of the cell into Power Query. That creates a query (let's call it Query1) with the value in a table cell You can then drill down into the cell to get its value, and then reference Query1 whenever you want to use that value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.