Formating table by comparing row cell values
Question
Application Type
Reactive
Service Studio Version
11.11.4 (Build 43498)

Hi there, 

I have a table, showing selected attributes of an entity. One of the attributes is a product name, next attribute a number for items in stock and additionally a date for edited on.

So the table can look like:

Product 1 - 15 - 01/06/2021

Product 2 - 15 - 01/06/2021

Product 3 - 15 - 01/06:2021

Product 2 13 - 02/06/2021 <-- this row should be red, because the number decreased

Product 3 - 30 - 03/06/2021 <-- this row should be green, because the number increased

Product 3 - 28 - 04/06/2021 <-- this row should be red, because the number decreased


How can I formate the table? Creating a new row, the logic has to compare the new value with the last value. However, I just know how the get the current value and not how to get the last value of the same product.



mvp_badge
MVP

Hi Axel,

It's difficult to answer your question without knowing what your data model looks like. How are the products and the stock stored?

Champion

Hello Alex

I have created one sample demo for you. Please have a look and confirm if you are looking for something like this - https://personal-9qwkrkgl.outsystemscloud.com/ForumHelp/TableStats?_ts=637592985199431956 


You can test by adding more values in product A,B, and C


Thanks

This looks like the solution for my problem. Very nice :)

How did you solve the problem?

Champion

Hello Alex

Please find the attached OML with the solution. 

I have basically added the conditional CSS to the ROW Cell that compares the last inserted value with the latest one and color the text. 


StockCompare.oml

Clever idea.

However, now I realize that my problem is a little bit more complicated.

I can't compare the last value with the latest one, because my list isn't sorted by date and every row is a different product.

The date is in one column and the rows are different products, filtered for the product name so that I see changes for one specific product.


Champion

I can't compare the last value with the latest one, because my list isn't sorted by date and every row is a different product.

--> Here, sorted by Date is not required. The data could be sorted by ID as ID is autoincremented. As far you want to compare the latest with last entry. Even if you enter data with same date it will work. 

--> Regarding every row has different product, I didn't understand. Can you show me in Excel or Table Structure how the data is managed and how to wants to maintain the comparison? 


I hope I will able to update the same solution in your structure too.

I tried to make a simplified example in Excel for my data / the structure of my data.

I filter the list for the same room and the product, so that I see the input and output of one product in the room. Regarding the example, I have to compare row 2 with row 3, later the comparision has to be made with row 3 and row 6 and last but not least row 6 with row 10.

So the number for product A in room alpha in row 3 has to be red (decrease from 50 to 40), in row 6 also red (decrease frin 40 to 30) and in row 10 green (increase from 30 to 80).

Exampledata.xlsx

Hi Axel,

If I were you, i would process my data between fetching them from the database and displaying them.  

There are probably ways of doing this smarter in a single SQL, but as long as performance is not an issue, I wouldn't bother.

See attached example,

Dorine

QDRUpOrDown.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.