cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
codyraptor Regular Visitor
Regular Visitor

Dax measure in a text box based on selected item

I'm looking to build a dynamic text box. It already shows a dimension when a selection is made, but I want to refer to a measure as well based on the selected item. Another words, if you select 'john' on a chart, then the text box will say John's yearly cost is 'measure'. I have the everything figured out except the measure piece. I tried using 'lookup', but that doesn't seem to work. Thanks!!!
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
codyraptor Regular Visitor
Regular Visitor

Re: Dax measure in a text box based on selected item

Hey Everyone,

 

Just tossing this bit of DAX language in here to show that the text can change based on the drill down in a chart.  Just took a bit of trial and error on my part.  See example below:

 

if(hasonevalue(name),

      values(name) & " text text text " & [measure] & " above plan " & etc.... ,

if(hasonevalue(name)&&hasonevalue(state),

      values(name) & " text text text " & [measure] & " above plan by" & [state],

 

etc...

 

The first IF statement will produce the text only if a 'name' is chosen.  The 2nd IF statement will produce text if both a 'name' and a 'state' is chose....so drilling down on a name in a chart to get to the level with a state..then selecting a state will produce the statement.

View solution in original post

7 REPLIES 7
Ross73312 Super Contributor
Super Contributor

Re: Dax measure in a text box based on selected item

Its going to depend on your slicer and what you can draw from it.  You could make use of FIRSTNONBLANK to get the text value of Johns name and then append it to the text you want.

 

https://msdn.microsoft.com/en-us/library/ee634210.aspx


   

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

Proud to be a Datanaut!


   


codyraptor Regular Visitor
Regular Visitor

Re: Dax measure in a text box based on selected item

I'm using Firstnoblank...to get John...do I just concatenate the measure to it with no lookup required? Another words firstnoblank(john) & 'measure'? I know that's not the exact formula..just getting the idea
Ross73312 Super Contributor
Super Contributor

Re: Dax measure in a text box based on selected item

No, the Dax language won't accept it as even though you know you've constrained the circumstances it still needs to treat it as a list of information.  Using "FirstNonBlank" gets around this and stops on the first value it finds thats that not blank.  Its going to have the performance saving you are expecting when you say you don't want a lookup.


   

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

Proud to be a Datanaut!


   


codyraptor Regular Visitor
Regular Visitor

Re: Dax measure in a text box based on selected item

K...so now I can't get a summarize columns expression to work.  Any suggestions?

 

Summarize Test = SUMMARIZECOLUMNS(Dispatch[MANAGER_NAME],Dispatch[MARKET],"Market",SUM(Dispatch[Dispatch Count]))

 

I'm basically trying to get a dispatch count grouped by Manager & Market.

codyraptor Regular Visitor
Regular Visitor

Re: Dax measure in a text box based on selected item

This is the full DAX code I'm using to find the max disp count by manager/market

 

MAXX(SUMMARIZECOLUMNS(Dispatch[MARKET],Dispatch[MANAGER_NAME],"Test",Dispatch[Disp Count]),[Test])

 

any help is greatly appreciated!

v-ljerr-msft Super Contributor
Super Contributor

Re: Dax measure in a text box based on selected item

Hi @codyraptor,

 

Could you post your table structures with some sample data and your expected result? So that we can better assist on the measures. Smiley Happy

 

Regards

Highlighted
codyraptor Regular Visitor
Regular Visitor

Re: Dax measure in a text box based on selected item

Hey Everyone,

 

Just tossing this bit of DAX language in here to show that the text can change based on the drill down in a chart.  Just took a bit of trial and error on my part.  See example below:

 

if(hasonevalue(name),

      values(name) & " text text text " & [measure] & " above plan " & etc.... ,

if(hasonevalue(name)&&hasonevalue(state),

      values(name) & " text text text " & [measure] & " above plan by" & [state],

 

etc...

 

The first IF statement will produce the text only if a 'name' is chosen.  The 2nd IF statement will produce text if both a 'name' and a 'state' is chose....so drilling down on a name in a chart to get to the level with a state..then selecting a state will produce the statement.

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 46 members 1,043 guests
Please welcome our newest community members: