# Math Filtering

**URL:** <https://community.glideapps.com/t/math-filtering/50243>\
**Category:** Ask for Help\
**Created:** [September 26, 2022, 11:41pm UTC](https://community.glideapps.com/t/math-filtering/50243 "2022-09-26T23:41:41Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 26, 2022, 11:41pm UTC](https://community.glideapps.com/t/math-filtering/50243/1 "2022-09-26T23:41:41Z")

</div>

Hello all,

I’m building a live dosing calculator in my app that requires different calculations for different medications in a particular order, but I’m having difficulty getting it to show up the way I need it to. Here’s what’s happening:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/b/4b1e0e05131c7cd8c0d47a81b5e38f845a66d52a.png)

The D10 and NS volumes are calculating appropriately; however, I need Dextrose to show in the app only when the SV column is 4201 and NS to show in the app only when the SV column is 4202, etc. I have close to twenty (20) different calculations that I still need to create, with different results appearing with each associated medication.

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/b/3b061323f40b673a7614a374e5daab78c25d01ad.png)

I’ve been using the hint components because my user base is familiar with the “Green = good / Yellow = caution / Red = ASK FIRST” rule, and it works appropriately with the medication names popping up, but right now, I can’t quite wrap my head around how to make the text line dynamic. In the picture above, the medication name (Normal Saline) is correct for the policy selected, but the dosing (2.1 gm / 21 mL) is associated with Dextrose from the policy above. Obviously, I can go into the Editor and change the text line so that it pulls from the NS Vol, but then it would change the text line for the other policies too (away from the template that I currently have).

I’ve tried everything I can think of so now I’m turning to the smarter people in the room. Please help! Thank you in advance!!

🙏  
Dustin

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 27, 2022, 12:05am UTC](https://community.glideapps.com/t/math-filtering/50243/2 "2022-09-27T00:05:03Z")

</div>

Can I assume that your screen is filtered where Policy Number is SV Policy Number?

If that’s the case, then isn’t a simple matter of pointing your Hint component at the Med 1 Dose column?

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 27, 2022, 12:45am UTC](https://community.glideapps.com/t/math-filtering/50243/3 "2022-09-27T00:45:47Z")

</div>

Hey Darren,

Thanks for the quick response. It would be that simple if I was using that column - I just haven’t deleted it yet. Those doses are all static and don’t apply to this particular sheet. I need to use the MATH columns.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 27, 2022, 12:50am UTC](https://community.glideapps.com/t/math-filtering/50243/4 "2022-09-27T00:50:41Z")

</div>

Which math columns?

Why can’t you just use a template column to join the bits together?

Sorry, but I don’t get what the challenge is. If your screen is filtered to the correct row (is it?) then you should be able to do whatever you want with the data in that row.

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 27, 2022, 1:00am UTC](https://community.glideapps.com/t/math-filtering/50243/5 "2022-09-27T01:00:25Z")

</div>

The math columns are in three of the last four in the screen cap of the Data Editor that I posted in my original post. And you are correct about the row being filtered correctly - which it is. The problem is that the the math columns are calculating in EVERY ROW, no matter which one that I select. I don’t need all of the calculations in the app, only the ones applicable to that specific row. When I change the template in the text element of the hint component so that it’s showing the data that I need, it shows that template in all instances of that component, regardless of the row chosen

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 27, 2022, 1:04am UTC](https://community.glideapps.com/t/math-filtering/50243/6 "2022-09-27T01:04:41Z")

</div>

> [@drascon](#):
>
> The problem is that the the math columns are calculating in EVERY ROW, no matter which one that I select.

That’s what a math column does.

> [@drascon](#):
>
> When I change the template in the text element of the hint component so that it’s showing the data that I need, it shows that template in all instances of that component, regardless of the row chosen

That’s to be expected, but I’d also expect to see data that’s appropriate to the selected row, so I’m still not understanding what the problem is.

Clearly I’m missing a key point somewhere - any chance you can make a short loom video and talk it through?

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 27, 2022, 1:34am UTC](https://community.glideapps.com/t/math-filtering/50243/7 "2022-09-27T01:34:17Z")

</div>

It seems that I didn’t clearly explain the issue that I’m seeking to resolve, so I apologize for the confusion. I am not under the impression that the Data Editor is doing something that it’s not supposed to; it is exhibiting expected behaviors and I am aware of this. I am also aware of what happens when a data point is assigned to a specific part of component in the app, and that it will continue to show what was chosen unless / until that data point is changed manually, making it a “static” value.

The issue that I’m trying to resolve is that I need the text element in the hint component to display dynamic dosing information based on the medication listed in the policy that is selected. Because the math columns are calculating across the entire row, I can only select one of the templates that I’ve created and I need the template to be based on the medication in each “Medication X (1, 2, 3, etc.)” Column.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/3/03b114084fa67bc2468963e5a3af42ec1e2c7ff1.png)

EX: in the screen capture above, the policy chosen is 4202, which appears correctly in the app (below). In the first hint component, it shows Normal Saline, which is the appropriate medication as detailed in the Medication 1 column.

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/2/52bf6a0d107e1b152f3793daa80db52ac4551e4e.png)

The text line, however, continues to show the template that I created for the preceding policy (D10 Template). I need it to show the calculation in the math column next to that so that it reads “82 mL” (from the NS Vol math column).

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 27, 2022, 1:44am UTC](https://community.glideapps.com/t/math-filtering/50243/8 "2022-09-27T01:44:45Z")

</div>

Sorry, still trying to wrap my head around this.

Can you explain the formulas in each of your math columns?

It looks like your template is joining the values in the D10 Dose and D10 Vol columns - what makes those values inappropriate for the current row?

What logic would you use to decide whether to display the D10 Template or the NS Vol column?

_Note: Please don’t take offence at all the questions, I’m just trying to get a clear picture in my mind what the actual challenge is. Once I have that, I expect the solution will most likely be self evident. I just need to keep prodding and poking until the penny drops_

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 27, 2022, 2:35pm UTC](https://community.glideapps.com/t/math-filtering/50243/9 "2022-09-27T14:35:45Z")

</div>



---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 27, 2022, 2:51pm UTC](https://community.glideapps.com/t/math-filtering/50243/10 "2022-09-27T14:51:41Z")

</div>

That’s really helpful.

It looks to me what you need to do is adjust the action on your Inline List.  
At the moment I’m guessing that it’s just doing a Show Detail Screen → This Item?

What I think you need to do is make that a custom action, with the first step being a Set Column Values that clears the value in that User Specific Column, followed by a Show Detail Screen → This item.

You could then add a visibility condition to your Hint component such that it’s only visible when the User Specific Column is not empty.

I’m pretty sure that should solve the problem, although the one thing I still find a bit confusing is where you say the template “holds” the previous value. Assuming that you’re attached to the correct row - and it looks like you are - I don’t see how that can possibly happen. Unless there’s something going on that I can’t see.

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 28, 2022, 9:04pm UTC](https://community.glideapps.com/t/math-filtering/50243/11 "2022-09-28T21:04:08Z")

</div>

Hey Darren,

Apologies for my delayed response. Thank you for the suggestions.

My inline list already has a custom action:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/1/319db234fc4cefdadfd9fd4e1257342468c5cef1.png)

The policy that’s selected from the inline list is entered as a SV on a different table, which is then used to “set” the same policy across three separate, but related, tabs:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/0/f0265c25ddcb8691423c2260e753ff81af35e2ad.jpeg)

(\*Disregard the last tab, that’s the one I’m currently working on.) From any of the tabs (seen above) the floating button uses another custom action to clear the policy value from the main SV column and return the user back to the inline list where they can pick another policy.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/e/3e8ffa9f001139a7df001e9160fbfc9fa58beb49.jpeg)

What I have setup so far in another GT (seen above) is essentially one big calculator that uses different formulas to calculate appropriate dosing and volumes based on industry accepted standard equations (usually mg / kg). The weight that was previously entered, as shown in the video, is pulled in here using a relation then the math columns do the rest. The templates are in place because the end users need to see both the dose as well as the volume that they need to administer.

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/5/b51da39d3ccbb057646ad2c71db9e90f387d6603.png)

(Above) What I need to figure out is how to setup a filter that will dynamically pull a template based on the medication that it’s associated with. Ideally, I’d like to be able to have the GT do all of the work so that there are generic “Medication 1,” “Medication 2,” etc. columns that can be plopped into one hint component. My only other thought is that I’d have to create 50+ individual hints, each with different associated templates, then make them conditionally available.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 29, 2022, 1:32am UTC](https://community.glideapps.com/t/math-filtering/50243/12 "2022-09-29T01:32:35Z")

</div>

> [@drascon](#):
>
> My inline list already has a custom action:

Okay.  
These sorts of details are important to mention, otherwise folks trying to help will be making incorrect assumptions and end up giving bad advice.

> [@drascon](#):
>
> The policy that’s selected from the inline list is entered as a SV on a different table, which is then used to “set” the same policy across three separate, but related, tabs:

I assume that Policy Number is a User Specific Column, yes?  
And then you use Single Value columns to apply the entered value to other tables?  
How is SV Policy Choice configured - is that taking the First Row-Whole Row from the target table, or?

I need time to digest all this a bit more. These sorts of things are really hard when you don’t have it in front of you. A bit like trying to solve a rubiks cube blindfolded…

But anyway…

> [@drascon](#):
>
> My only other thought is that I’d have to create 50+ individual hints, each with different associated templates, then make them conditionally available.

If that ends up being your only option, I’ll eat my shoe 😉

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 29, 2022, 4:51pm UTC](https://community.glideapps.com/t/math-filtering/50243/13 "2022-09-29T16:51:18Z")

</div>

> [@Darren\_Murphy](#):
>
> Okay.  
> These sorts of details are important to mention, otherwise folks trying to help will be making incorrect assumptions and end up giving bad advice.

I know, I know 🤦‍♂️ I’ve been working on this app for the last 2+ years and being so close to it makes it hard for me to remember that the backend may be more / less complicated than someone else’s. Articulation is key!

> [@Darren\_Murphy](#):
>
> I assume that Policy Number is a User Specific Column, yes?  
> And then you use Single Value columns to apply the entered value to other tables?  
> How is SV Policy Choice configured - is that taking the First Row-Whole Row from the target table, or?

Yes and yes and whole row.

> [@Darren\_Murphy](#):
>
> If that ends up being your only option, I’ll eat my shoe 😉

![](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/6/6654ebc1d902251b92b8a1d8009ef5c124eb83d4.gif)

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [September 30, 2022, 11:14pm UTC](https://community.glideapps.com/t/math-filtering/50243/14 "2022-09-30T23:14:25Z")

</div>

I THINK I GOT IT!!! 🤯

- I have a single value column pulling in all first line medications from a different table  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/7/27ec3509a8672c35dd739358229d1df92faab271.png)

- The math columns do the heavy lifting then I use a template to join the dosing and volume together  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/b/0be538309dab7158c63ed840b030dfe8b5edee84.png)

- I used an ITE column and built it so that "If Medication 1 is (the name of the med being pulled into the SV column), then _THIS TEMPLATE_, pointing it to the template that I want associated with that medication.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/1/d1635b5e11f0510630c054d5541cb6feae2de7ad.png)

- In the other table, where I have all of the protocols already built out, I added a lookup column to look up the ITE column that’s pulling the live calculations.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/9/b9f16f14b37d8224196b1a485d9ba87ea0f68325.png)

- In the text line of the hint component, I directed it to the lookup. BOOM.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/e/ee6e59e4fb0d836342925527d31a465f3296c6b8.png)

It seems to work so far but my head is gonna explode from looking at this thing for the last few days so I’m gonna take the weekend off from it and come back to it on Monday with fresh eyes. I’ll keep you posted @Darren_Murphy!!

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [October 1, 2022, 5:16am UTC](https://community.glideapps.com/t/math-filtering/50243/15 "2022-10-01T05:16:55Z")

</div>

> [@drascon](#):
>
> I THINK I GOT IT!!! 🤯

Excellent!  
So I can put my shoe back on then? 😁

---

<div class="post-metadata">

**Author:** ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)\
**Post date:** [October 1, 2022, 5:58pm UTC](https://community.glideapps.com/t/math-filtering/50243/16 "2022-10-01T17:58:18Z")

</div>

Not yet… if it works then yes. If not, then it’s your fault 😝

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [October 5, 2022, 8:31pm UTC](https://community.glideapps.com/t/math-filtering/50243/17 "2022-10-05T20:31:02Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
