how to make text box dynamic

I have a dimension product_name, and my requirement is that in dashboard I want to show user with the text: “Hello ABC, this month your most sold product is XYZ”.

I am able to achieve text: “Hello, ABC” in a tile by using dummy dimension, how can I do the same in text box component (is this even possible that we can add some dimension in text box ?):

9236c137-ee72-47da-9b88-57a9476ea470.png

Second thing is that How to find most sold product using LookML so that I can add that into my text box, I know that using SQL I can achieve this but how to implement same using LookML.

0 3 2,768
3 REPLIES 3

Hello! 

You will need to create a visualization for this, you can’t inject sql in a text box. What you can do is create a Look that will have:

  • Filter: Purchase Date matches (advanced): This Month
  • Dimension: Product Name
  • Measure: Count of Product Sold

Order your view by the Count of Product Sold in descending order and add a row-limit of 1. Then you can create a Table Calculation and add the following formula: 

concat("Hello, this month your most sold product is ",${product.name})

You can then hide the Product name dimension and the Count of Product Sold measure from your view (by clicking on the gear icon next to the column name in your data section). You may select a table visualization or single value visualization to display the info.

Hope this helps

Hello! 

You will need to create a visualization for this, you can’t inject sql in a text box. What you can do is create a Look that will have:

  • Filter: Purchase Date matches (advanced): This Month
  • Dimension: Product Name
  • Measure: Count of Product Sold

Order your view by the Count of Product Sold in descending order and add a row-limit of 1. Then you can create a Table Calculation and add the following formula: 

concat("Hello, this month your most sold product is ",${product.name})

You can then hide the Product name dimension and the Count of Product Sold measure from your view (by clicking on the gear icon next to the column name in your data section). You may select a table visualization or single value visualization to display the info.

Hope this helps

Thanks for the response, how can I add username in table calculation, I have dimension like below in my view  

 dimension: login_User_Name {
type: string
sql: 1 ;;
html:
Hello, {{ _user_attributes['name'] }}
;;
}

When I am using this in table calculation its giving me ‘1’ instead of user name.how can I fix it?

You will need to change your dimension declaration to: 

dimension: test_username {
type: string
sql: '{{_user_attributes['name']}}' ;;
html: <p>Hello, {{rendered_value}} </p>;;
}

and then you can add this new dimension to the concatenation 

concat("Hello, ", ${user.login_user_name}, " this month your most sold product is ",${product.name})

HTH

Top Labels in this Space
Top Solution Authors