Simply counter don't work

I’m trying to create a simple counter that counts state changes but I’m making a mistake somewhere. Please help. Data in the sitemap is not displayed.

Items

Number counter

Sitemap

Text item=counterW

Rules

var Number counter = 0
rule “counter”
when
Item CPU_Load1 changed
then
counter = counter + 1
postUpdate(counterW)
end

Your Item could be:

Number counterW

Then in your rule something like:

postUpdate(counterW, counter)

You can’t define an Item and a var with the same name, and expect them to be connected.