Passing visual selections to Translytical Task Flows with DAX

Introduction

A common misconception about Translytical Task Flows is that the only way for you to parameterize and pass user inputs to the User Data Function, is through Slicers in Power BI.

That is not true at all.

In fact, one of the most powerful ways of integrating Task Flows into your Power BI reports, is by allowing user selections made in visualisations in your report, flow through to your task flow.

In today’s article, we take a look at how DAX and Calculated Measures can help you pickup the existing context of your user, to dynamically affect your Translytical Task Flows.

This blog is the sixth in a series on Translytical Task Flows. Check out the other ones below:

Converting User Selections to Task Flow inputs with DAX

Basic Method

The general idea of this technique, is to use DAX expressions to return whatever value(s) the User has currently selected in their Power BI report.

To do this, we can take advantage of the fact that User Selections in Power BI applies filters on the underlying Semantic Model. This means, that we can extract the currently filtered values, by calling DAX expressions such as SELECTEDVALUE().

SELECTEDVALUE(‘columnname’) returns the value selected by the user on the defined column, given that there is indeed only one distinct value available in the filtered context.

As an example, I can use the below measure to pick up the context of the Product being selected by the user:

In my Translytical Task Flow action, I can now map this Measure to my parameters by using the Conditional Formatting option (as long as the data type matches the type expected by the parameter, just like is the case with mapping slicers to parameters):

Notice how Measures with wrong data types are greyed out.

Advanced Method

To take things a step further, I wanted to show that you can of course build in additional logic in your DAX measures, by combining SELECTEDVALUE() with other DAX functions.

In my example below, I would like to automatically register if the user is on the Top or Bottom level of the hierarchy in my Bar Chart, so that I can use that information as a parameter in my Task Flow, without the user having to manually select anything.

To accomplish this, I constructed a simple measure combining SELECTEDVALUE() with HASONEVALUE() in a conditional measure.

When the User is at the ProductCategory level, the measure returns “ProductCategory”:

And when the user is as Product level, the measure returns “Product”:

Again, I can map this to my Task Flow exactly like before:

Closing Remarks

The sky is the limit here.

There is absolutely nothing stopping you from using any other DAX function and advanced filtering technique you can think of. All that matters is that the Value(s) that you return with your Measure, has to match the data type of the parameter in your Translytical Task Flow.

You could use ConcatenateX to pass a list of values as a single record to your Task Flow, to be parsed out later. Perhaps even VALUES() works for sending an entire table or column, but I have not yet tested this.

You could use ISFILTERED() and ISINSCOPE() as detailed in my blog post last year, to extract the correct information from Hierarchies, in case the HASONEVALUE() technique above wasn’t enough.

I find SELECTEDVALUE() sufficient for most of my use cases, but I would love to hear about other use cases for DAX in Translytical Task Flows.

Also check out these other blogs:

Bulk Write-Back w. Translytical Task Flows in Microsoft Fabric / Power BI: Writing a single value back to multiple records at the same time

Introduction On this blog we’ve previously covered quite a few areas of Translytical Task Flows: Having presented a few sessions on Translytical Task Flows at conferences in the past moths, there is one major recurring question: How do you write-back multiple records at once? If you ask me, the questions of bulk write-back/writing back multiple…

Fabric Quick Tips – Pushing transformation upstream with Self Service Views and Tables in Visual Queries for Lakehouses/Warehouses/SQL DB

Introduction Recently, I’ve experienced a huge influx in requests from Microsoft Fabric customers wanting a good way for user’s to push data transformation upstream, following Roche’s Maxim: Data should be transformed as far upstream as possible, and as far downstream as necessary. To elaborate slightly, there are tons of Power BI Semantic Models out there…

Organizing your Microsoft Fabric Data Platform: Tags and Task Flows

Introduction We’ve arrived at the final level of detail in our series on Organizing your Microsoft Fabric Data Platform. So far we’ve covered, from broadest to narrowest scope: This time we go all the way down to the Item level on our platform, and describe strategies for labeling and categorising individual items by using Tags…

Something went wrong. Please refresh the page and/or try again.

One response to “Passing visual selections to Translytical Task Flows with DAX”

Leave a comment