I am attempting to make a graph that has one column with a full month of data (black bars), and one column that fills up as the days of the month progress (green bars). I would also like to track the percentage of the forecast achieved each day as a line graph (red line) on the secondary axis.
The problem I am having is that it does not appear that one can exclude values that are zero. So in the graph I would like to have the red line disappear once the values become zero so that there isn't a massive drop of like in the image shown.
To fix this problem I inserted a blank spot if the condition is true. That is a "" after the 'then' statement to force a NULL. After this I changed the data type to percentage.
The code is shown below and the resulting graph is shown afterwards.
= Table.AddColumn(#"Filtered Rows1", "AdjDiff", each if [#"%difference"] = 0 then "" else if [#"%difference"] <> 0 then [#"%difference"] else null)
Related
I'm not sure if this is possible but as you can see I have a pivot table with multiple dependent and expandable fields. I am trying to concatenate the data from columns A:D into one cell which works fine in row 2 but doesn't work with blank parent cells, as you can see in column F.
Any ideas for how to achieve this?
Pivot table
This answer assumes that you don't want to just Repeat All Item Labels in the PivotTable from the "Report Layout" drop-down on the Pivt Table Tools "Design" tab.
A formula to get the first non-blank value on or above the same row as the current cell from Column B can be constructed with a combination of AGGREGATE, SUMPRODUCT and OFFSET, like so:
=OFFSET($B2,SUMPRODUCT(AGGREGATE(14,6,ROW($B$1:$B$100)*--(ROW($B$1:$B$100)<=ROW())*--(LEN($B$1:$B$100)>0),1))-ROW(),0)
How does it work?
Starting with the outermost part, OFFSET($B2, VALUE, 0) - this will start in cell B2, then look up or down by VALUE rows to get the value.
Next we need to know how many rows we will need to look up-or-down. Now, if we can work out the bottom-most row with data, we can subtract the current ROW() from that, giving us OFFSET($B2, NON_BLANK-ROW(),0)
So, to finish up we need to work out which rows are not blank, AND which rows are on-or-above our current row, then take the largest of those. This is going to take an ArrayFormula, but we can use SUMPRODUCT to make that calculate properly. To find the largest number we could use MAX or LARGE - but we get less errors if we pick AGGREGATE(14,6,..,1). (The 14 means "we want the kth largest number", the 6 means "ignore error values", and the 1 is k - so "we want the largest number, ignoring errors")
But, what list of numbers are we going to look at, I don't hear you ask. Well, we want the ROW for output from our range (I'm using $B$1:$B$100, because using the whole column B would take far to long to calculate repeatedly), a comparison against the current ROW(), and check that the LENgth is > 0. Those last two are comparisons, so let's write them out first:
ROW($B$1:$B100)<=ROW()
and
LEN($B$1:$B$100)>0
We want to use -- to convert TRUE and FALSE to 1 and 0 - this means that any "bad" values become 0, and any "good" values are larger than 0:
ROW($B$1:$B$100)*--(ROW($B$1:$B$100)<=ROW())*--(LEN($B$1:$B$100)>0)
This gives us the Row number when the Row is on-or-before the current row AND Column B is not blank - if either of those are False, then we get 0 instead. Stick that in the AGGREGATE to find the largest number:
AGGREGATE(14, 6, ROW($B$1:$B$100)*--(ROW($B$1:$B$100)<=ROW())*--(LEN($B$1:$B$100)>0), 1)
Then put it in a SUMPRODUCT to force Excel to treat it as an ArrayFormula, and that's your NON_BLANK. This then gives you that first formula right at the top of the post
I am creating a StackedArea chart in VB.NET and I have some data rows which contain all 0 but one value which is for example 10.
When I draw these values, I loop over all these values, draw a zero and then continue with the next point. An example data row looks like this:
"january",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.03,0.10,0.00,0.00,0.67,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00
As one can see in the in the blue line, there is still something (let's say 1px) displayed, even if the values are all 0.
My code to draw these series looks the following:
Chart.Series.Add(item(1))
For i = 2 To 25
Dim cell = worksheet.Cells(item(7), i)
Chart.Series(k - 1).Points.Add(cell.Value)
Next
Chart.Series(k - 1).ChartType = SeriesChartType.StackedArea
Chart.Series(k - 1).BorderWidth = 0
Does anyone have any idea what is going on? Thanks in advance.
In the only row group I am trying to get a alternate row color with the following expression:
Expression for background color : =IIf( RunningValue (Fields!SP.Value, CountDistinct, Nothing) MOD 2, "White", "blue")
SQL code:
select
ROW_NUMBER() OVER (ORDER BY DataDate) AS SSRSRowNumber
,datepart(dw,datadate) SSRSDateFilter
,DataDate
,SP
,sum(TMI) as TotalCI
from table
where DataDate>GETDATE()-20
group by DataDate,SP
order by 1, 2
The result is the picture below, what's wrong in the expression listed above?
Edit-:Solution
The missing dates in your data is causing the issues with the background row color not working correctly.
You can waste lots of time trying to make your query work.
Or you could just use the Alternating Row Color function.
Private bOddRow As Boolean
'*************************************************************************
' -- Display green-bar type color banding in detail rows
' -- Call from BackGroundColor property of all detail row textboxes
' -- Set Toggle True for first item, False for others.
'*************************************************************************
Function AlternateColor(ByVal OddColor As String, _
ByVal EvenColor As String, ByVal Toggle As Boolean) As String
If Toggle Then bOddRow = Not bOddRow
If bOddRow Then
Return OddColor
Else
Return EvenColor
End If
End Function
For the first column that controls the color:
=Code.AlternateColor("AliceBlue", "White", True)
For the remaining columns, don't toggle with the third argument:
=Code.AlternateColor("AliceBlue", "White", False)
You may need to switch the colors in the first column in a matrix.
SSRS Alternating row color issues when some rows are not visible
This has occurred for me where I don't have an intersection between my row groups and column groups.
Example:
- I have stored procedures 1 and 2
On 1/1, both 1 and 2 ran, so I record them
On 1/2, only 1 need to run, so I only record 1
On 1/3, they both ran again, so I recorded both
I'm going to have a messed up looking cell on 1/2 for sp 2 (the color won't change) because SSRS can't calculate a new value for the running total (it's still 1). On 3, it recognizes a value and gets that the running value is now 3, so coloring resumes as expected.
To solve this, you could perform a cross apply to get the cartesian product of all dates and SPs so that every distinct date has a row for every distinct date and store this in a temp table. Store your current query in a temp table or CSV and join onto your cross apply based query. This will ensure no missed cells. Note, this will have a performance impact so test accordingly (it is most likely negligible).
Let me know if you need help writing the queries.
I try to put in SSRS in a chart bar a target line and a baseline. I add in my chart with stripline a target line. But I would like to show it like this:
The chart1 is the chart which I would create in SSRS. And the chart2 is the chart which I create in SSRS. How can I add only one bar at the beginning of the chart.
I assume there is a parameter or equivalent identifying where the Baseline should be (even if it is the current date)
If so, you can have the baseline series to only display a value for the column you want to set as the baseline.
In this example I have a number of students, and want to display a baseline column where the student name is Student1
Add a new series to the chart, and set the expression to be
=iif(Fields!Student.Value = "Student1", Sum(Fields!Val.Value), 0)
This will mean that it will only return a value when the column is for Student1, otherwise it will return zero.
Conversely, you could set the other columns to be values except for when they are Student1 as follows
=iif(Fields!Student.Value <> "Student1", Sum(Fields!Val.Value), 0)
Using a Stacked Column chart for these series would give this output
Alternatively, you could use dates for the X axis, and use a parameter to set the date for the baseline, and use a expression such as this to identify the baseline column
=iif(Fields!myXAxisDate.Value = Parameters!myBaselineDate.Value, Sum(Fields!mYValue.Value), 0)
Hopefully this will assist you. Please let me know if you have further questions on this.
I have an application that keeps rent periods of a parking lot. I have a SQL database with this information:
idLot dateFrom dateTo
------------------------------------------
1 01/03/2011 30/07/2011
2 01/01/2011 30/05/2011
3 01/02/2011 30/07/2011
6 01/02/2011 30/06/2011
And I need to display the information like the image below.
1
I cannot achive the goal with Excel or Crystal Reports. I also use ComponentOne FlexGrid. Any ideas?
Thanks in advance.
It's not the prettiest option, but you can do this in Excel using the Sumproduct() function. In the screenshot below, the sumproduct goes through each line of your datatable and does 3 things (the selected cell is B17 by the way):
It determines whether each row has the idlot it is looking for (evaluates to true/false)
It determines whether DataFrom is <= the column of your display table (evaluates to true/false)
It determines whether DataTo is >= the column of your display table (evaluates to true/false).
This results in a 0 or 1 in each cell of your display table. This is close, but not exactly what you're looking for. I then added some conditional formatting:
If the result of the equation was 0, then the cell's font is white.
If the result of the equation was 1, then cell's font and background are both green.
When you apply the conditional formatting to the entire graph, you get the last 2 rows, which is green for occupied and white for unoccupied.
The only remaining problem is how to account for a changing number of rows in your table. This can be solved by just setting the ranges in your equation to a very high number.