I am stuck in figuring out complex calculations involving multiple conditions. I request your help in finding the right direction & logic for solving it.
As seen in the below image, I have a table listing the areas & nos of different rooms. The Available Nos is entered by the user while filling the form. I am stuck at calculating the Required Nos for the corresponding rooms.
The conditions for arriving at Required Nos for each room differ from one another. For example, No. of Class Room = (No. of Divisions * Course Duration). No. of Tutorial Room = (No. of Classroom / 4) the fraction should be rounded to next integer.
No. of Laboratory = 10 per Course.
I request your help in understanding which components can be used for calculating these values and how to fill the dynamic table with these values for comparison.
Yes, the variables are coming from the same query. It is a nested query, and the course duration & no. of divisions are part of the main table & the room details are part of the sub-table
Sorry but it just happened to have a service visit for my internet line upgrade to fiber optics...
From what I understood these are the calculations: No. of Class Room = (No. of Divisions * Course Duration).
No. of Class Room = divCount * courseDuration
No. of Tutorial Room = (No. of Classroom / 4) the fraction should be rounded to next integer.
No. of Tutorial Room = (query_instructionalAreaUGCourses.count() / 4).ceil()
**I'm not sure if (No. of Classroom) is correctly pointed to query_instructionalAreaUGCourses.count()
No. of Laboratory = 10 per Course.
No. of Laboratory = 10 * query_instructionalAreaUGCourses.count()
If you don't get the right calculations let us know... Maybe I understood wrong a variable
I'm not sure about one thing: No. of Tutorial Room = (No. of Classroom / 4) the fraction should be rounded to next integer.
**(No. of Classroom) is correctly query_instructionalAreaUGCourses.count() ?
Anyway, can you check if the results on this table are correct?
Hey Many Thanks @famousmag the solution is working perfectly.
I have few other conditions to be applied for other rooms, is this the best way to continue using Ternary Operator or there might be some other easy solution to the problem.
I just want to understand, what would you, being an expert, do in such a scenario?
Glad it worked for you.
*I'm not an expert... Just trying buddy
Ternary operator would be fine i suppose for this kind of "one shot" inline conditional results.
In other cases you would like to filter your whole repeat procedure, you could use the formatters like .where() , .filter() etc, directly on your datasourse/expression