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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
calimero48
Helper II
Helper II

Dax query paremeter in Power BI import request

Hi

I have an DAX query with a parameter (codegpt) working as expected in DAX studio

EVALUATE

Var _phylevel2=SUMMARIZECOLUMNS(
Client[code],
FILTER(ALL(Client[GPTCOD-LV2]),Client[GPTCOD-LV2]=@codegpt))
return _phylevel2

 

I want now import the result in PowerBI desktop.

So
I created after the paramter codegpt ( Tick enable load and include in refresh report ).


I create a connexion to my SQLserver Analysis Server and paste my query to the DAX query.

 

And I got the error saying paremeter is codegpt is  not declared.

 


What I am doing wrong?

 

Thanks in advance for your help

1 ACCEPTED SOLUTION

Hi 

 

Thanks you for your response.

I succced to do it.


Just for others if this can help , my code:

let

codegpt = Text.Combine({ Character.FromNumber (34),CodegptParameter, Character.FromNumber (34)}),

QueryParamter=Text.Combine({"DEFINE var cdegpt=",codegpt}),

ActualQuery="

EVALUATE

Var _phylevel2=SUMMARIZECOLUMNS(
Client[code],
FILTER(ALL(Client[GPTCOD-LV2]),Client[GPTCOD-LV2]=@codegpt))
return _phylevel2",

finalquery=Text.Combine({QueryParamter,ActualQuery}),

source=AnalysisServices.Database("servername", "databasename", [Query=finalquery, Implementation="2.0"])

in

source

 

Best Regards

View solution in original post

4 REPLIES 4
v-deddai1-msft
Community Support
Community Support

Hi @calimero48 ,

 

You need to update your desktop to the latest version and selected it in preview feature and restart it. It is provided for m-query based source. Please aslo refer to https://blog.crossjoin.co.uk/2020/12/06/using-power-bi-dynamic-m-parameters-in-dax-queries/

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Hi 

 

Thanks you for your response.

I succced to do it.


Just for others if this can help , my code:

let

codegpt = Text.Combine({ Character.FromNumber (34),CodegptParameter, Character.FromNumber (34)}),

QueryParamter=Text.Combine({"DEFINE var cdegpt=",codegpt}),

ActualQuery="

EVALUATE

Var _phylevel2=SUMMARIZECOLUMNS(
Client[code],
FILTER(ALL(Client[GPTCOD-LV2]),Client[GPTCOD-LV2]=@codegpt))
return _phylevel2",

finalquery=Text.Combine({QueryParamter,ActualQuery}),

source=AnalysisServices.Database("servername", "databasename", [Query=finalquery, Implementation="2.0"])

in

source

 

Best Regards

v-deddai1-msft
Community Support
Community Support

Hi @calimero48 ,

 

In power bi, we can't use query parameter directly in dax formula. You many need to use slicer or what-if parameter to hold the @codegpt in your post: https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-what-if and https://community.powerbi.com/t5/Desktop/use-parameters-in-dax/m-p/536343

 

 

And you can also refer to the following preview function: https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

 

Hi

 

The only solution I see it's:
 https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters

 

But i do not see how to implement it.

 

Best Regards

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.