Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting the background color of a specific cell in table

Hi All,

I am new in Qlikview. I ran into the following.

I developed a Qlikview document that opens a list of computers from a database.

I want to ping the computernames and mark them as Present (green background) or Absent (red background), depending the result of the ping.

The routine for pinging works OK.

But I can't find a way to mark the cell red or green. I tried the doc's and API guide, but I can't find what I'm looking for.

I pull in the data to a table. I can get the text from the field for the computer name.

How do I set the background color for a cell from within a macro??

12 Replies
swuehl
MVP
MVP

You run the ping in your load script? Do you use the result to set values in a tables field?

If so, you might have a table like

ComputerName, Alive

Server1, 1

Server2, 1

Server3, 0

....

For example, In a straight table you could use the visual cues to set the background colors depending on Alive Flag ( a table box misses that feature, I think).

Create a straight chart, set ComputerName as dimension and Alive as expression.

In Visual cues tab, set the upper and lower limits to 1 resp 0 and set the colors for text and background as you like.

Hope this helps,

Stefan

Not applicable
Author

Hi Stefan,

THX.

I run the ping by pressing a button, but running it at load time might also work.

I have to experiment with the straighttable, I'm quite new in Qlikview. The idea is good.

swuehl
MVP
MVP

If you want and if needed you could post your example app here in the forum (upload available in advanced editor), so it is easier to help you if you have more questions.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Once you have the data in a straight table, you can also set the background of the cells conditionally. On the expressions tab, click the small + sign next to the expression, select Background, and enter the expression in the Definition box, something like =If(Active, Green(), Red())

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Seems I´m totally stuck here.

I figured out how to make a straight table and I can add a field for the result of the ping.

When I use SetInputFieldCell to set the content, when running the script, the script stops and shows the straight table with a grey cross in it and the script pops up. No errors, no results.

Searching the Internet it looks like I must use an input field.

I can´t figure out how to make an input field. I can declare it in the script, but it shows as a variable, not as a field.

I´m using the free professional version, so examples won´t work.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Hi,

You may not be able to open our files but users of the full version can open yours so post your qvw and someone may be better placed to help. I'm not quite sure I follow what you're doing can you confirm I have understood the following correctly?

1. You load the computer names from a DB table but not the latest ping results.

2. You are running a macro from within QV to ping the computers?

If I have understood you, you could do something like create a variable vResults and use the macro to write a delimited string of results to the variable. E.g. vResults = "computer1:1,computer2:0,computer3:1,computer4:1," (ensure final comma) etc. Then, in a straight table chart add ComputerName as the dimension and in the expression use the following:

=TextBetween(vResults,ComputerName & ':',',') to show the results in a nice table.

Then, in the background colour expression use:

IF(TextBetween(vResults,ComputerName & ':',',')=1,LightGreen(),Red())

Hope this helps,

Jason

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Oops - the webpage text editor changed my & ampersand to amp: - you'll need to ignore that!

swuehl
MVP
MVP

Hi desperado,

I don't think you necessarily need an input field here, but maybe I misunderstood your problem.

Besides that, SetInputFieldCell is an automation interface member so how do you use it?

Anyway, I think you could execute an (external) command script in the Qv script part to ping your machines. This script could (in a simple approach) just writes the results back to a file and this file could be read in by QV. I believe more fancy solutions without the need for the external file will also be possible.

But since your original question was about highlighting the results in a specific table cell, I concentrated on this part 😉

So please have a look at my attached file.

- pscript.cmd is a simple batch file that pings machines and writes results back to a file (list of machines is read in from file iplist.txt).

- pingtest.qvw executes this batch file during load, then reads in the created file and voila - here you go with your results table

- in the QV document, I used an expression for the expression attribute background colour, to highlight the failed pings then (you could also use visual cues or some other formatting (text style, dimension name formatting,...)). I added some examples how to highlight.

Hope this helps,

Stefan

P.S:you might need to adjust the parse phrase "Lost" in the batch command file to your localized phrase for lost pings returned by your OS

Not applicable
Author

Hi All,

THX for replying.

@Jason:

What I'm trying to accomplish is this. I want to use the report together with an asset management application. In the database I have a list of equipment details from computers, network equipment, printers etc (assets), including the name of the asset. I want to make a kind of dashboard with an overview of the equipment and I want to show if it is "alive" in the network.

The list might be long, so pinging every asset on load time is (when I think about it) not desired because the load time can be long. I implemented a button with a macro (VBS) to perform the ping on demand. As desired a warning can be given that execution might take a while.

So in the database tables is nothing like a ping result.

I attached my current QV doc. It uses a plain table with the computer name, the OS version and the assigned user. Nothing fancy.

And the macro returns an error on inserting the text in the table.

Thanks in advance,

Mario