I have a set of data and i have a macro running adding a line each 5 seconds This is linked to a pivot-table and a pivot-chart in a Dashboard
Looks like this (picture is my 2nd version with incremental instead of decremented)
I have a field in a hidden page where i put how many of the last logged line i want to see
For example i have 1000 lines and i want the dashboard graph, to the press of a button, toggle between "see only last X" or "see all"
I want to find a lighter way to do what i have done cause i see a big latency
I have achieved this by adding two columns in my data with a macro writing formula in them in a way that
Col D : give a value to the line
Col E : if the value of D > 0 write "last X logs" and the rest "before X logs"
I put this code for Col D
Settings!I4 = Field where i but the amount of logs i want Ex; 15
Settings!I5 = Is where i store the last row value to be used in the formula thus updating all the line at each added lines
setsheet.Range("I5").Value = lastrow
logsheet.Range("D" & lastfreerow).Value = ("=Settings!I4-(Settings!I5)") & "+" & setsheet.Range("I5").Text
This write the formula in the cell and look like this :
=Settings!I4-(Settings!I5)+7
the result is a count down where the most resent value is "15" and the oldest goes in the negative
And put this code for Col E
logsheet.Range("E" & lastfreerow).Value = "=IF(RC[-1]>0,""Last"" & "" "" & Settings!R4C[4] & "" logs"",""Before the last"" & "" "" & Settings!R4C[4] & "" logs"")"
This write the formula in the cell and look like this :
=IF(D8>0;"Last" & " " & Settings!I$4 & " logs";"Before the last" & " " & Settings!I$4 & " logs")
And i use those those "values" in the slicer that sort my pivot-table
thank you