cancel
Showing results for 
Search instead for 
Did you mean: 

How to create WEBI Variable ?

guozheng_chen
Explorer
0 Kudos

How to know the 'HEIDESTRASSE' include how many 'S' ,how to create formula ?

View Entire Topic
ayman_salem
Active Contributor
0 Kudos

Out-of-the-box is not possible (there is no function to do this)

Workaround:

With Javascript in the WebI report, you can do the following:

- Define a variable with the following Javascript code

="<script>
function getCount(sStr, sChar) {
var count = 0;
for (var i = 0; i <  sStr.length; i++) {
    if (sStr.charAt(i) == sChar) {
        count++;
    }
}
return count;
} 
</script>

<script>var count=getCount('"+[City] + "','s'); document.write(count);</script>"

Note : replace the [City] with your dimension, 's' with your search character

..

- Add a column with the variable to your table and format the cell to read the content as HTML.

...

Hopefully this workaround will help you meet your needs

guozheng_chen
Explorer
0 Kudos

When I copy the script into WEBI, cannot count the column.

0 Kudos
I tried to implement your example but I can't get it to work. I wanted to understand it because what I'm really looking for is to be able to display a dynamic size table in an HTML cell, for example I want to fill it with the values of the city object recovered in the query. I imagine that with javascript I could fill the table dynamically. If you have any idea how to do it, would you be so kind as to send me an example? My email is gscheidegger@aluar.com.ar. Thank you.