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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Edit Variables as Slicer or dropdown for the user

Hi,

 

I am using HANA view as a data source for my Direct Query Power BI Desktop Report.

HANA View works on mandatory variables that need to be passed such as 'UNIT' in which the data will be calculated by the view.

In direct query mode i see 'Edit Variables' option under Edit queries to change the values of these variables.

Is there any option using which i can create a slicer or dropdown for the end user to change the values easily instead of going to Edit queries.

Also , is there any way by which we can change values of these variables after publishing report to Power BI Service.

 

Any suggestions

 

Thankyou in advance

 

Regards

Power BI User

 

1 ACCEPTED SOLUTION

@Anonymous,

You have created a parameter named Unit, and define some values for it , right? If so, change {Cube.ApplyParameter,"UNIT",{'"&Unit&"'}} to the following:

{Cube.ApplyParameter,"UNIT",{""&Unit&""}}

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

hi..just wondering how you manage to see the edit variables button? As mine is disable and grey out even though i use hana view direct query

Anonymous
Not applicable

Hi I am also facing the same issue and How to create the growth calculations in power bi Because I am using SAP HANA datasource direct query...?

 

Anonymous
Not applicable

Hi

 

I think you can use quick measure or create measure to create measures in Direct query mode as well.

 

Capture.PNG

 

Regards

Power BI User

v-yuezhe-msft
Employee
Employee

@Anonymous,

Do you create parameters in Query Editor of Power BI Desktop? If so, do you use the paramter to filter your source or rows in your table? If you use the parameter to filter the rows, you may create measure instead. Please share sample data of your table and post expected result  based on sample data here.

In addition , when you create parameter in Power BI Desktop, currently it is not possible to change the values of the parameter after publishing report to Power BI Service.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thankyou for your response v-yuezhe-msft    🙂

 

I am not using Parameters. I am using Variables which appear by default when i connect with HANA Views in Direct Query mode as these variables are present in HANA Views.

 

Capture.PNG     

 

When i click on edit variables , this variable window opens. I can change values of the variables from here.

My question is if we can make these variables available to user on the report itself as a list , slicer or dropdown for ease of use and so that when i publish my report to service these variables are available to user for changing values.

 

Power BI User

 

 

@Anonymous,

You would need to create parameters in Query Editor of Power BI Desktop for these variables, then apply these parameters into M code of your Query. This way, you can edit parameter values in dropdown list in Report view of Power BI Desktop, and you are able to change the parameter in Settings of Power BI Service.

There is an example for your reference.
1.PNG2.PNG3.PNG4.PNG5.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Lydia,

 

Thankyou for your response 🙂

 

Since my dataset is huge i can't use import mode, i am using Direct Query Mode.

In direct query mode edit parameters option (Create Parameters) is disabled.

 

Although let me try using import mode if passing values to HANA variables is possible through parameters.

When i use import mode , we need to pass values to HANA View Variables to import Data.Therefore it generates the Mquery according to that.Capture.PNG

 

Unit , Time_Frame and Material are HANA View Variables . Fro example 'kboe' is a value i passed to Unit variable to import data.I want to create a parameter for it , so i used :

{Cube.ApplyParameter,"UNIT",{'"&Unit&"'}}

where Unit is a Parameter.

It also does not seem to work for me.It does not do anything.

Please suggest

 

 

Regards

Kanika Jain

@Anonymous,

You have created a parameter named Unit, and define some values for it , right? If so, change {Cube.ApplyParameter,"UNIT",{'"&Unit&"'}} to the following:

{Cube.ApplyParameter,"UNIT",{""&Unit&""}}

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks a lot Lydia.

 

This solution worked for me :).

 

One of my Parameter is of type integer.

Capture.PNG

 

I am using the following syntax for passing parameter Year_Start

{Cube.ApplyParameter,"Year_Start",{"&Year_Start&"}},

 

This statement throws the following error below :

Capture3.PNG

 

Can you please suggest

 

Regards

Power BI User

 

@Anonymous,

Please check my second reply in this thread. Create the Year_Start parameter in Text type, then use Number. FromText() function.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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