One of the cool things that was shown when NAV 2013 first came out was that you could make “Green Bar” formats for your reports to make them easier to read. Something like this…
Recently, I had to replicate an old NAV 2.01 report
for a client. Since we couldn’t do green-bar back then, I had an option
to double space the report to make it easier to read:
It was simply a check-box on the options tab. I went
ahead and put it on the new NAV 2015 report for them. After I did that, I
decided to give them the Green-Bar option as well. That way they could
still have readability, but not have to double the paper usage on the
report. So, in addition to the “Double Space Report” check box, I also
added a “Green Bar Format” checkbox to the option tab on the Report Request
Window.
Then I decided to play around a little bit and created a
“test” version of their report. First, I made the green-bar print every
third line instead of every other line. It still accomplished guiding the
user’s eye across the report, but made the report a lot less “busy”. I
liked that enough that I put that change into their live report.
Next, I decided to see what other things I could do with the
report so I changed the “GreenBar” global from a Boolean to an Option
field. I made the options” ,,2,3,4”. Then I changed the green bar
formula to look at the option and space the green lines accordingly.
Here’s what it looks like when selecting “4” as the option…
Here’s the nested-IF formula that I put in the “Background Color” property of the row in the Tablix control:
=Iif(Fields!GreenBar.Value > 0, Iif(RowNumber(Nothing) Mod Fields!GreenBar.Value, "NoColor", "LightGreen"), "NoColor")
The “RowNumber” variable is a built in variable in the report writer. Interestingly, if I also choose the “Double Space” option on the request form, it will print the green-bar every 8 lines instead of every 4. That’s the because the “RowNumber” is looking at the rows of data instead of the rows of output on the report itself.
The “Mod” function is something that I used about every 5 years in previous versions of NAV. It’s used to see if a number is evenly divisible by another number. In other words 8 Mod(2) is True because 8/2 = a full number with no remainder. But 9 Mod(2) is False. (But you probably already know about the “Mod” function.)
Here is a shot of the Tablix control…
You can see the “blank line” below all of the other
fields. That’s used for the “Double Space” option. If you
right-click on the little box on the left side of the grid, you can see the
options available. Choose the “Row Visibility”.
The line above all of the data fields is actually “hidden”
and contains the variables to print in the header. This is fairly
standard NAV although most NAV reports have these rows super scrunched down so
they’re had to see/ and hard to click on in order to see the contents of the
field.
A couple of other things:
- Notice the color “LightGreen” in the formula for the green bar. I actually used “LightGrey” for the client’s report thinking that it might render a little cleaner on the laser printer.
- If you just manually select a color from the color palette, it will display in the “tool tip” as you hover over the color window as “Light Green” (notice the space). But if you enter the space in the formula, it won’t work.
- “LightGrey” displays as “Light Gray” in the tool tip when you hover over the color palette.
- Some of the results that you’ll get if you Google “Green Bar Reports NAV2013” will have you enter “White” whereas I used “NoColor”. Again, my thinking is that it might be better for the rendering if the printer isn’t trying to create a “white background”. This may or may not be true or significant.
I’m sure that none of this is rocket science, but I wanted to pass it along. Maybe this will save someone some time and trouble in the future.