Select to view content in your preferred language

Dynamic Content Expression

9936
10
Jump to solution
11-20-2020 06:23 AM
JasonCyphers
Occasional Contributor III

Trying to have text that counts the number of records in a database in which a specific attribute is "Yes".

What formula do I need to enter into the Expression box, so that if 3 of the 5 records have "Yes" for a specific attribute, then the number displayed is "3"?

JasonCyphers_0-1605881731908.png

 

1 Solution

Accepted Solutions
BrunoSousa1
Occasional Contributor

Hi Jason,

You can create a View of your layer within Experience Builder and filter to only the ones that say Yes. So, in the expression box you insert Count() and select which view the data is coming from, if it's default or the data view you created:

Create the Data View here:

BrunoSousa1_0-1605883441412.png

 

Select the Data Views when you connect the widget to data

BrunoSousa1_1-1605883548075.png

Insert COUNT() and select whitch data view it's counting from:

BrunoSousa1_2-1605883634649.png

 

Let me know if this helps.

Best

View solution in original post

10 Replies
BrunoSousa1
Occasional Contributor

Hi Jason,

You can create a View of your layer within Experience Builder and filter to only the ones that say Yes. So, in the expression box you insert Count() and select which view the data is coming from, if it's default or the data view you created:

Create the Data View here:

BrunoSousa1_0-1605883441412.png

 

Select the Data Views when you connect the widget to data

BrunoSousa1_1-1605883548075.png

Insert COUNT() and select whitch data view it's counting from:

BrunoSousa1_2-1605883634649.png

 

Let me know if this helps.

Best

JasonCyphers
Occasional Contributor III

Awesome, thanks!!

Is there, by chance, a way to perform a calculation to show the feature count, that has the attribute as "Yes", as a percentage of the total features in the database?  

JasonCyphers_1-1605886993751.png

 

 

BrunoSousa1
Occasional Contributor

There is. You can add COUNT()/COUNT()*100, and select the data views for each COUNT(). However the result has lots of decimals and I don't know how to change that

JasonCyphers
Occasional Contributor III

Thanks again!!

 

haha, yea, need to figure out a way to format the text to limit the decimal places!

JasonCyphers
Occasional Contributor III

Is there a way to do any conditional formatting?  If the expression resulted in a value 50% or more, could you format the text to be bole red, otherwise it remains the default?

0 Kudos
Lucasrodri
New Contributor

Hi !!

Do you know a way to change the decimals now? Im overthinking with that hahaha

0 Kudos
RobertAnderson3
MVP Regular Contributor

I know this was months ago, but if you're still struggling with this, next to the Insert when creating the expression there is a gear icon for settings, there is a number formatting option in there and you should be able to use that to decide how many decimals!

0 Kudos
TKSHEP
by
Occasional Contributor

Any help you can provide would be greatly appreciated, I tried this, and it did not work.  I am unable to get the count work properly.  Any suggestions, I do not need the percentage just the correct number to show for all attributes with a "NO".

Thank you!

0 Kudos
BrunoSousa1
Occasional Contributor

Hi Trisha. Did you select the DataView?

The DataView must be selected on the right side panel:

BrunoSousa1_1-1669831190547.png


Then you must select the DataView before adding the Statistics "Count":

BrunoSousa1_2-1669831256918.png


Let me know if it doesn't work

0 Kudos