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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anmolgan
Post Prodigy
Post Prodigy

How to write a DAX which should calculate as per parameter passed?

I want to write a DAX which should calculate some conditions according to the value passed by user in the parameter, what I am trying to say is I want to calculate closing and opening balance for which dates are passed by the user in the parameter and after when it runs every calculation for the dax should be on the behalf of that parameter is this possible? Can anyone point me in the correct direction?

7 REPLIES 7
JarroVGIT
Resident Rockstar
Resident Rockstar

If my understanding of your problem is correct, then this is definitely possible.

You need to make sure your parameters are loaded into the datamodel zo you can reference them into your DAX expressions. By default, parameters are not loaded into your datamodel.
To do this, right click on the parameter in the query editor and select "Enable Load".

Now, if you reference the parameter in your DAX expressions, you can use the value given by your users.

If this answers your question, please mark it as solution 🙂




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Also whenever I try your method to load the parameter directly into the model, I lost the option to change the parameter in PowerBI Service itself, earlier I was using a blank query to take the values of the parameter whenever I change and I was using that table inside the DAX formulas and I was getting the option to change the parameter to any give values in the powerbi service, can you explain what I did wrong here so that i can get back to parameter change option in powerbi service?

Then I really don't understand what you are trying to achieve. You already had a working workaround for my initial understanding of your problem. Isn't the model reloaded every time you change your parameters, and thus also your dax expressions reevaluated?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I am looking for a way to not refresh the entire query because it takes 30-40 mins to run and re extract all the data from SAP BW enviroment to PowerBI, Am looking for a way to change the parameters and get the desired output in PowerBI Service itself, is that possible?

Hm I see what you are getting at. Unfortunately I am unaware of a way to reload parts of a dataset in PowerBI Service, and the parameters are part of the dataset once uploaded to the Service. If you change the parameter (online in the Service) you need to refresh the dataset in order for the change in parameters to take effect. 

One possible solution (and i am unsure if that works with SAP BW as well) is incremental refresh. You will need to have Power BI Premium capacity available to you though. This might drastically decrease the amount of time it takes to refresh the dataset once you've changed the parameters. I have little experience with this though, so more on the subject i wouldn't be able to tell you. If you don't have PowerBI Premium available to you, then using parameters are maybe not the right solution to your need? Perhaps creating measures and allowing your consumers to change said measures?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Seems like a probable solution, but the end user will never be able to use the powerbi desktop that freely like a user do using the PowerBI Portal.

@JarroVGIT 

 

Thanks for you response, I think you understand my problem correctly, and solution is also correct as that is something that I am looking for but my scenerio is somewhat different here. 

 

I am using the SAP BW connector in order to connect to On-Premise SAP BW system, now the problem is everytime I change my parameter I need to refresh the data in order for my query to take that parameter and calculate everything from scratch, what I am looking for is, a way so that I dont have to refresh my dataset each time I change my parameter, since Query refreshing makes refreshing of the powerbi query and powerbi needs to refetch the data everytime I refresh the query and it takes 30minutes or so to make the refresh and give me the new parameter, How can I dynamically change the parameter so that each time I change the parameter powerbi do not need to refresh the whole query and it should only refresh the parameter to reflect the updated value, in the end I am only making relatioship of my data parameter into the SAP-BW query so that everytime the parameter changes it should take that current date into the query and display the values with all the formulas.

 

Is that something that is possible?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors