How to display the value based a criteria from another column

Hi,

I know this could be something basic, but I have no idea how to do it.

So let say we have a data set like below:

How to code to display the value for only the 75T type? If I do {{#1001}} the number is the SUM of both rows. Also, how to code to display the Test Percentage?

Please advise and thank you very much.

Hi again @Mojo

we recently added a case about the functionality you are looking for, the where function.
You can now filter out data that have certain values. You can find here how to : CASE: where attribute

Further, I think that also answers your second question about the Test Percentage? You can call upon the variable in your for-loop.

If you need further help with that, don’t hesitate to upload your code so we can have a further look.

Kind regards
Sofie

Thanks @Sofie_Cleemput. I do notice that in the case you shared, it still requested user to make a selection in the input mode so that the value can passed to the calculation. My question would be if it is possible when I code it I directly do something like {{ #1001 | where:“Type”=“75T” }}. I know this is not a valid code, but I just want to inquire if I can code with logic like this? Please advise.

Hi @Mojo

we can indeed code it with the logic you explained. In this case I would do something like this :

{% stripnewlines %}
| Value
| Percentage
| Type
{% newline %}
|--------
|--------
|--------
{% newline %}
{% assign types = "75T|95T|Other" %}
{% fori test in custom.some %}
  |{% input test.value as:currency %}
  |{% input test.percentage as:percentage %}
  |{% input test.type | as:select | options:types %}{% newline %}
{% endfori %}
{% endstripnewlines %}

{% assign chosen_types = custom.some | where:'type','75T' %}

{% for chosen_type in chosen_types %}
{% $1+ chosen_type.value %}
{% $2+ chosen_type.percentage %}
{% endfor %}

Total value of type 75T: {{ $1 | currency }}
Total percentage of type 75T: {{ $2 | percentage }}

With this code, you get the following result :

I hope this will meet your expectations. If not, please do let us know.

Kind regards
Sofie