Execute DAX from a button

Hi,
This is just a general question around buttons …. Is it possible when a button is clicked that a measure is evaluated and based upon the result an action take place (similar to an OnClick event)?

Any advice would be great! Thanks.

@Kazza ,

Terrific question. I think technically the answer is “no”, but practically speaking I think depending on what you’re trying to do with the button, you could use some combination of bookmarks and/or conditional page navigation to effectively fake that effect.

  • Brian

Thanks so much Brian. How ironic, I have just finished watching that video and thought that I could potentially use that! I really don’t want to us a dropdown or a list, I need that to be actioned via a button. I wonder whether I can implement a workaround by superimposing a button over the list/dropdown to achieve the same result?
Cheers, K

@Kazza ,

You definitely don’t need to control the page navigation through a slicer. The conditional formatting of the button lets you tie it to any measure though the most common use case I’ve seen is definitely to have that measure branch based on the selection from a disconnected table. Keep in mind that SELECTEDVALUE has the oft-ignored second parameter, which is the value it takes if nothing is selected or if the function can’t narrow to a single value. That may be something you can use to get the effect desired.

It might be helpful if you could specify a particular use case, and we could brainstorm on how to achieve the desired action. My experience though is with some creativity, and the combination of bookmarks, page nav and drillthrough tied to buttons, you can simulate almost any effect.

Here are a couple more videos that might provide good ideas:

See what you think. I hope this is helpful.

  • Brian
1 Like

Hi @Kazza , good to see you back in the forum :slight_smile:

Did the response provided by @BrianJ help you solve your query?

If not, how far did you get and what kind of help you need further?

If yes, kindly mark as solution the answer that solved your query.

Good morning Brian.
Apologies for my tardy response. We have just come off a National holiday on Friday which gave us a long weekend hence I wasn’t reading any emails/notifications.
Your response did give me some ideas. Thanks so much for chasing this up as I do appreciate the support.
However, what I am actually after is to dynamically add a measure to an existing bar chart. I want to achieve that by avoiding bookmarks or creating another page. I know how to add the measure dynamically by using a slicer as a list but was hoping to use a button such as a toggle button instead of the list. For example, similar to an on/off switch - either to add the measure or not to add the measure. I am only going to have one choice in the list (Show ) so I was wondering whether there was a way to achieve this? If I can’t that’s fine I would then need to retain the slicer list or go down the path of a bookmark or page navigation.
Thanks again!
Cheers K.

@Kazza ,

I have given this a lot of thought and I don’t think there’s a way to do this without using a slicer, bookmark or page navigation.

The closest approach I can think of is to use a list slicer and hide all but one visible option. Thus, instead of an on/off button you’d have an on/off checkbox.

  • Brian
1 Like

Hi @Kazza, we’ve noticed that no response has been received from you since September 27.

We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved.

Hi @Kazza, due to inactivity, a response on this post has been tagged as “Solution”. If you have a follow question or concern related to this topic, please create a new thread.