Check monthly value reduction in a consumption history

I have a database with historic mothly of energy cosumption of the users.
I need check if there is reduction of consumption equal to or greather than 20% and save this month to a value.
I tested with Math Formul check "Month*0,8 >= Month -1), but this mode need very columns.
I need way more simple. How can i do? With Loop?

Dataset

Hi @glaysontkd

Welcome to the KNIME Community!

You can do this in multiple ways, I’ll give two:

Use the Lag Column node to retrieve the value of the previous month (the -1 column in created) .

Next, use a Math Formula node to apply your 80% calculation. I opt to store this in a separate column in case you want to keep the original value. If you need to apply this to multiple columns, use the Math Formula (Multi Columns) node.

Use a Rule Engine node to compare the two and determine if the condition is being met (opting for TRUE/FALSE here).

$kwh_0.8$  >= $kWh(-1)$ => "TRUE"
TRUE => "FALSE"

Based on your example, this is all FALSE.

image

  1. Use a Column Expression node and the multi row access feature. This combines the steps of option 1 by using:
if (column("kWh") * 0.8 >= column("kWh",-1)) {
    "TRUE"
} else {
    "FALSE"
}

Under the Advanced tab of the Column Expression, ensure that you have multi-tow access enabled with a sufficient window size that suits your case (you have quite some rows). Use the checkbox for Value in first (last) row.

image

See WF:
Check monthly value reduction in a consumption history.knwf (29.5 KB)

Hope this helps!

2 Likes

Thankyou!
Sorry. the photo only had one user but there are more.

Your workflow is very funcion but there is in DataBase a lot Users (CDC), them Lag + Math Formula ends up getting data from the user above.
I tested with GroupBy, but without sucessfull.

How can i do ?
DB.xlsx (329.0 KB)

Hi @glaysontkd

Add a Group Loop and select CDC as grouping column.

Then the Column Expression or the Lag Node route as mentioned before and finally a End Loop. That will make sure each user is analyzed individually.

1 Like

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