I have an ssrs matrix which looks like the one below :
Month(Columns)
Product(Rows) Sales(Data)
The output looks something like this :
June July August Sept Oct
ABC 34 34 23 22 67
DEF 33 21 32 22 14
I want an output that looks like this :
June July June-July Aug July-Aug Sept Aug-Sept Oct Sept-Oct
ABC 34 34 0 23 11 22 1 67 45
DEF 33 21 12 32 11 22 10 14 8
I tried doing something like this :
Month(Columns) Change
Product(Rows) Sales(Data) Expression
The expression looks something like this :
=Sum(IIF(Fields!MONTH.Value=Fields!MONTH.Value,Fields!Products.Value,Nothing))-
Sum(IIF(Fields!MONTH.Value=Fields!MONTH.Value - 1,Fields!Products.Value,Nothing))
But it doesnt work . I want to see the output as shown above . Please let me know.
Hey Sam ,
With the solution you mentioned :
I see an output like this :
June Garbage July July-June Aug Aug-Jul
ABC 34 xx 34 0 23 11
DEF 33 xx 21 12 32 11
Is there a way we can remove the column with the garbage values ?
Hey Sam , I tried your code. Now I have a big white space all along the column. Is there a way I can hide the wide space too ?
If you are grouping your columns by month then you don't need to use the SumIif
You can use a expression such as =Sum(Fields!Products.Value) to get the sum of all products in that particular month. If you want to see the difference between the current month and the previous month then if you enter the below expression in a cell within the month column group...
=Iif(Previous(Fields!MONTH.Value) = Nothing, 0,
Sum(Fields!Products.Value) - Previous(Sum(Fields!Products.Value)))
You need the null check in this instance as the first month will return nothing for previous.
If you have overlapping row and column row groups (which I believe you do) then you won't be able to use Previous as it isn't supported :-(
I think that the only solution is to use some custom code.
There is a link here
Public Shared previous as Integer
Public Shared current as Integer
Public Shared Function GetCurrent(Item as Integer) as Integer
previous=current
current=Item
return current
End Function
Public Shared Function GetPrevious()
return previous
End Function
Then your usage would be something like
=Code.GetCurrent(Sum(Fields!Products.Value)) - Code.GetPrevious()
I found a way to calculate the differences between Matrix columns using the 'previous' function by adding the column grouping name.
=Previous(Sum(Fields!AMOUNT.Value),"PeriodGroupName")
Look here for a little more detail.
http://www.tricks-and-tips.nl/tips-and-tricks/sql/ssrs/ssrs-matrix-compare-column-values
And here for the documentation.
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms156372(v=sql.105)
Related
I'm new to working with files in C...just started this week. I would appreciate your help...
I'm working with files and structures in C. Running the program, I ask for information to fill in several fields.
here is the content of the file:
111 12 2 2022 12 0 13 2 2022 14 0 opolisttt listtt ttt
The correct should be:
111 12 2 2022 12 0 13 2 2022 14 0 opo lis ttt
For sure I'm doing something wrong, I just don't know what... Any help?
Problem solved: as #SergeBallesta wrote, I had to add 1 to all character arrays. I just had troubles when I used the full length of the array, then, no space for the null terminator.
I am new to array formulae and have noticed that while SUBTOTAL includes many functions, it does not feature COUNTIF (only COUNT and COUNTA).
I'm trying to figure out how I can integrate a COUNTIF-like feature to my array formula.
I have a matrix, a small subset of which looks like:
A B C D E
48 53 46 64 66
48 66 89
40 38 42 49 44
37 33 35 39 41
Thanks to the help of #Tom Shape in this post, I (he) was able to average the sum of each row in the matrix provided it had complete data (so rows 2 and 4 in the example above would not be included).
Now I would like to count the number of rows with complete data (so rows 2 and 4 would be ignored) which include at least one value above a given threshold (say 45).
In the current example, the result would be 2, since row 1 has 5/5 values > 45, and row 3 has 1 value > 45. Row 5 has values < 45 and rows 2 and 3 have partially or fully missing data, respectively.
I have recently discovered the SUMPRODUCT function and think that perhaps SUMPRODUCT(--(A1:E1 >= 45 could be useful but I'm not sure how to integrate it within Tom Sharpe's elegant code, e.g.,
=AVERAGE(IF(SUBTOTAL(2,OFFSET(A1,ROW(A1:A5)-ROW(A1),0,1,COLUMNS(A1:E1)))=COLUMNS(A1:E1),SUBTOTAL(9,OFFSET(A1,ROW(A1:A5)-ROW(A1),0,1,COLUMNS(A1:E1))),""))
Remember, I am no longer looking for the average: I want to filter rows for whether they have full data, and if they do, I want to count rows with at least 1 entry > 45.
Try the following. Enter as array formula.
=COUNT(IF(SUBTOTAL(4,OFFSET(A1,ROW(A1:A5)-ROW(A1),0,1,COLUMNS(A1:E1)))>45,IF(SUBTOTAL(2,OFFSET(A1,ROW(A1:A5)-ROW(A1),0,1,COLUMNS(A1:E1)))=COLUMNS(A1:E1),SUBTOTAL(9,OFFSET(A1,ROW(A1:A5)-ROW(A1),0,1,COLUMNS(A1:E1))))))
Data
If I have three dates, e.g. Jan 1, Jan 25, and Feb 20 but I want the dates to be separated by 30 days, how can i do it?
For example, what I want to do is Jan 1, Jan 30, Feb 29.
I am very new at R but the code should be something like this - If 2nd date is before (1st date+30), then adjust 2nd date to (1st+31) and similarly for 3rd date..
Any help will be much appreciated!
Since you want a fixed distance between each adjacent pair of dates, you don't need to "adjust" any dates; rather, you can just compute the desired date vector from scratch, starting with the first date.
This can actually be done with a single call to the S3 generic seq(), which will dispatch to seq.Date():
seq(as.Date('2000-01-01'),by=30,length.out=3);
## [1] "2000-01-01" "2000-01-31" "2000-03-01"
Also note that you seem to have made an error in deriving your expected dates; 30 days from Jan 1 is Jan 31, not Jan 30.
d1 = as.Date("01-01",format="%m-%d")
d2 = as.Date("01-25",format="%m-%d")
if (abs(as.numeric(difftime(d2,d1)))<30) d2 = d1 + 30
>d2
[1] "2015-01-31"
If I have a column of dates and a corresponding column of volume data, like this:
31,3
31,2
31,1
31,5
07,2
07,3
07,4
07,2
07,3
07,5
07,3
07,1
07,1
07,2
07,3
30,5
06,4
I want to add up the data in the right hand column, for each date. If I use accumarray like this:
orgSumVinDay=accumarray(dayIdx,vv);
k=orgSumVinDay==0;
SumVininDay=orgSumVinDay;
SumVinDay(k)=[]
It works; I get:
11
29
5
4
which is correct because on the 31st, there were 3+2+1+5=11, etc.
However, I want to get a column showing the cumulative addition within each day, so that it looks like:
3
5
6
11
2
4
9
11
14
19
22
23
24
26
29
5
4
and I'm not sure how to achieve this. Thanks!
Cannot check it right now but I believe you should be able to do it with accumarray (..., [], #cumsum). The last parameter will replace the default function sum with cumsum.
I am having difficulties with making an array formula work the way I want it to work.
Out of a column of dates which is not sorted, I want it to extract values into a new column. The formula below identifies the required cells of a given month and year, but they appear in their original row rather than on top of the output range. Moreover, I want all ""/FALSE cells to be excluded from the output array.
=IF((MONTH($I$15:$I$1346)=1)*(YEAR($I$15:$I$1346)=2008),$I$15:$I$1346,"")
In fact, the $I$15:$I$1346 should be dynamic and go to the last filled range (I could make a named range for that)
Part two is to expand on that formula so that it calculates the data that is an two column offset of the data described above.
Is the above possible to build into one cell probably with a combination of IF, INDEX, SMALL and maybe others?
I'm not looking for a filter solution. Hope the above is clear enough and that you can help!
Here's a shortened sample layout:
A B C
1 Date Series_A Series_B
2 03/01/2011 45 20
3 04/01/2011 73 30
4 06/01/2011 95 40
5 08/01/2011 72 50
6 06/02/2011 5 13
7 09/02/2011 12 #N/A
8 05/02/2011 23 65
9 07/03/2011 12 65
Then I want three input cells for the year and and the month and series name (index/match, as there are many more columns with data). If it would be 2011, Feb and Series_A, I want it to calculate the average for that month. In this case it would be (5+12+23)/3. If it would be Feb-2011 and Series_B instead, which has an error, it should show (13+65)/2 rather than an error.
Aside from that I want a separate which will output an array with the data instead without 'holes' in between and with the right 'length'. Example for Feb-2011 in Column C:
A B C D
1 Date Series_A Desired Output Output based on f above
2 03/01/2011 45 5
3 04/01/2011 73 12
4 06/01/2011 95 23
5 08/01/2011 72
6 06/02/2011 5 5
7 09/02/2011 12 12
8 05/02/2011 23 23
9 07/03/2011 12
If I then run a =ISBLANK(C5) it should be true, rather than =""=C5
Hope the edit clarifies
I reached out to various platsforms to get an answer, and here you have one which is ok. Still doesn't fully answer part 1, but works nonetheless.
http://www.excelforum.com/excel-formulas-and-functions/905356-exclude-blank-false-cells-in-in-excel-array-if-formula-output.html