Google Spreadsheet get unique values from two different sheets - unique

Thanks in advance for your help!
I have two tabs, Events1 and Events2, each of which contain dates in column A. In another tab, Summary, I have successfully pulled the following info:
[1] A sorted list of the unique dates from Events1 column A; this was extracted using this formula =join("; ",unique(query(Events1!$A$2:$A$125,"select A where A is not null order by A")))[2] A sorted list of the unique dates from Events2 column A; this was extracted using this formula =join("; ",unique(query(Events2!$A$2:$A$125,"select A where A is not null order by A")))
Now, what I am trying to figure out how to do is, in tab Summary, pull:
[3] A sorted list of the unique dates from both Events1 column A and Events2 column A.
Example Events1 column A Events2 column A
June 12, 2014 June 14, 2014
June 11, 2014 June 14, 2014
June 12, 2014 June 13, 2014
June 13, 2014
June 13, 2014
Then [1] returns "6/11/2014; 6/12/2014; 6/13/2014" and [2] returns "6/13/2014; 6/14/2014". And I would like [3] to return "6/11/2014; 6/12/2014; 6/13/2014; 6/14/2014".
I hope I explained that properly. Thanks!
Tess

FYI I solved this using a hidden sheet.
Within the hidden sheet I created a column where I put in the top data cell:
=transpose(sort(split(join("; ",Summary!B12,Summary!B13),"; "),1,TRUE))
And then within the Summary sheet I pulled the info I wanted with this:
=join("; ",unique(query('Hidden sheet'!$A$2:$A$250,"select A where A is not null order by A")))

Related

How to tie the column visibility expression in SSRS to current year and current month?

I have an SSRS report that has all 12 months as columns and one more column called "Year". I already have a condition set that takes the current month of the report run date and displays only the months that have passed. For example, the expression looks like this for March =IIF(Month(today()) < 3, True, False).
Now I have to tie this to the Year column as well. The condition is- if the Year column has years prior to the current year, the condition above should not apply. So, if I am running 2020 data today, all 12 month columns should appear. If I am running 2021 data, I should only see the January column. Can some one please help me with this? And yes, there will only be one year in the "Year" column. The data will never have more than one year.
Thank you.
Edit 1:
If the report is run for 2020, the data should look like this on the report.
If it is run for 2021, only the YEAR and JANUARY columns should appear. Starting February of this year, YEAR, JANUARY, AND FEBRUARY should appear.
As your dataset is not normalised, you will have to set the column visibility on each column as you are doing already.
Try using the following expression. (using March as an exmaple)
=(Month(today()) < 3 AND MAX(Fields!Year.Value, "DataSet1") = YEAR(Today())
Note: The "DataSet1" reference is the name of your dataset. It is case sensitive and must be enclosed in quotes as shown above.
There is no need for the IIF() expression as the above will return true if either condition is met.
Alternative
If your data was normalised (you may be able to edit your dataset query) and looked something like this...
Year Month Amount
2021 1 10
2021 2 15
Then you could simply use a matrix instead of a table, and have a column group by month. There would be no need to set visibility on anything as the data simply is not there so no column would be rendered for the months with no data.

Populate a cell in SSRS report by testing value conditions from other column value

Populate a cell in SSRS report by testing value conditions from other column values
I have 3 columns (category, Month, Amount) in my dataset, with values similar to these below:
Category Month Amount
A Jan 20
A Feb 25
A Mar 10
R Jan 15
R Feb 50
R Mar 55
On the report I need:
Jan Feb Mar
A 20 25 10
R 15 50 55
I have tried placing this expression in each group row column, for example, in the "Feb" column it would be:
=IIF(Fields!Category.Value = "A" and Fields!Month.Value = "Feb", Fields!Amount.Value, 13)
Using IIF, which does not short-circuit, is not evaluating the conditions properly. The "Month" value being a string, it displays always the first row found for the conditions, in this case it would display value 20, instead of 25. If I change the "Month" value to int, it displays the false(13);
How can I populate my cell correctly, using IIF or something other way?
Any help on this is deeply appreciated.
You don't need to do anything like that.
Just use a matrix instead of a table.
Add the matrix to the report, you'll see three placeholder names, (from memory) something like Rows, Column and Data. Drag your Category field to the rows cell, your month field to the columns cell and your Amount field to the data cell. That's it....
The only problem you will have is the columns would be ordered alphabetically by default. It would be better to have the Month number in your dataset too so you can order by that. You set the column order by right-clicking the column group name in the row/column group panel which is under your main report design area.

SSRS 2016 - Line Graph will not chart multiple series

Using SSRS 2016 and SQL 2017 Report Builder
I have a dataset like the following. It has event dates and attendance:
Event_Date Attendance
1/1/2016 1
2/1/2016 2
3/1/2016 3
4/1/2016 4
5/1/2016 5
6/1/2016 6
7/1/2016 7
8/1/2016 8
9/1/2016 9
10/1/2016 10
11/1/2016 11
12/1/2016 12
1/1/2017 5
2/1/2017 6
3/1/2017 7
4/1/2017 8
5/1/2017 9
6/1/2017 10
7/1/2017 11
8/1/2017 12
9/1/2017 13
10/1/2017 14
11/1/2017 15
12/1/2017 16
I am attempting to create a line chart in an SSRS report where there is a datapoint (Attendance) for each element in the series. I am specifying two series -- Series 1 is the attendance for 2016 and Series 2 is the attendance for 2017. Each series will be on a separate line in the chart. The purpose is to visually compare attendance in 2016 vs 2017.
The date periods are determined dynamically by report parameters when the report is run for one series and by variables calculated from the report parameters for the other series.
In the line chart I have defined:
Values are Attendance
Category Groups are Event_Date (with a filter to select events in 2017)
Series Groups are Event_Date (with a filter to select events in 2016)
PROBLEM
When I run the report, the graph renders but has no data (lines).
If I remove the Series Group (events in 2016), the graph renders correctly with only the data line for 2017.
I've been working on this for quite a while and I am stalled trying to figure out what is going on.
Does anyone have any ideas as to why both series are not being graphed and how to fix it?
Many Thanks!
Note: The solution is simple, don't be put off by the length of the reply ! :)
You'll need to make a few simple changes to your dataset query..
Here's a sample query I used to replicate you data.
DECLARE #t TABLE (Event_Date date, Attendance int)
INSERT INTO #t
VALUES
('1/1/2016', 1),
('2/1/2016', 2),
('3/1/2016', 3),
('4/1/2016', 4),
('5/1/2016', 5),
('6/1/2016', 6),
('7/1/2016', 7),
('8/1/2016', 8),
('9/1/2016', 9),
('10/1/2016', 10),
('11/1/2016', 11),
('12/1/2016', 12),
('1/1/2017', 5),
('2/1/2017', 6),
('3/1/2017', 7),
('4/1/2017', 8),
('5/1/2017', 9),
('6/1/2017', 10),
('7/1/2017', 11),
('8/1/2017', 12),
('9/1/2017', 13),
('10/1/2017', 14),
('11/1/2017', 15),
('12/1/2017', 16)
select Event_Date, format(Event_Date, 'dd/MM') as DayMonth, year(Event_date) as Yr, Attendance from #t
Notice in the final select (the bit you actually need) I've added a year column Yr and a day/month column DayMonth. With your dataset as it was, even if you split by year the x axis would still represent the date so the you two lines would have been next to each other rather than one on top of the other which is what I expect you want....
The result of the dataset gives us something like...
Event_Date DayMonth Yr Attendance
2016-01-01 01/01 2016 1
2016-02-01 02/01 2016 2
.....
.....
2017-01-01 01/01 2017 5
.....
.....
And so on..
Now, add a new line chart and drop Attendance into Values; DayMonth into Category Groups and Yr into Series Groups.
Your chart design should look something like this...
That's it!
When we run the report we get this...
Thanks so much for the help. It pushed me in the right direction so that I could make things work for the situation.
I made some changes to the query so that I could align all the data on top of each other by a yearly event number.
Here is the query:
select
ROW_NUMBER() over (PARTITION BY year([dbo].[#temp_table_4].[event_start_date]) ORDER BY [dbo].[#temp_table_4].[event_start_date]) as yearly_event_number
,format ([dbo].[#temp_table_4].[event_start_date],'d') as event_start_date
,format([dbo].[#temp_table_4].[event_start_date],'MM/dd') as MonthDay
,year([dbo].[#temp_table_4].[event_start_date]) as Year
, Count (*) as [Total Attended]
from
[dbo].[#temp_table_4]
Group by [event_start_date]
order by
[dbo].[#temp_table_4].[event_start_date]
The main change was that I needed to number each event that happened each year beginning with 1 and ending with 'n' (the last event of the year). I needed to do that because the events don't happen on the same date each year (they actually happen each Wednesday which is not the same date each year).
To account for this, I added the following SQL clause:
ROW_NUMBER() over (PARTITION BY year([dbo].[#temp_table_4].[event_start_date]) ORDER BY [dbo].[#temp_table_4].[event_start_date]) as yearly_event_number
In the chart, I assigned Total_Attendance to Values, yearly_event_number to Category Groups and Year to Series Groups. I also added a tool tip that showed the event date so that you can hover over any point and show the event date.

Graph in SSRS only shows a couple of week's data

I'm making a graph in SSRS which will highlight the sales for each week from a specific week, and from 52 week up to that date.
For this I have created the following data set in SSRS:
WITH SET LAST52WEEKS AS
{
STRTOMEMBER("[Dim Date].[Week].&[2017]&[1]&[1]&[4]").Lag(52):
STRTOMEMBER("[Dim Date].[Week].&[2017]&[1]&[1]&[4]")
}
Select {[Measures].[Quantity]} ON 0,
{Last52Weeks} ON 1
FROM (
Select {
[Dim Store2].[Store Key].&[1024]
} on columns
from [DSV_FactStoreSales 1]
)
which works as intended, and have an output for week 13 through 4 with each week having a weekly sales Quantity>400 (except for one week with Quantity (null).
However, when I add this data as the Y-axis in a graph in SSRS along with Weeks attribute as the X-axis, only four rows are returned. The rows returned are for the weeks
1,19,3,40
All other values are blank in the graph. Does anyone have any idea as to why this may occur?
Regards,
Cenderze
EDIT updated x-axis from using Interval value = 1
When I changed the Interval value under Horizontal Axis Properties I now get the following values for the x-axis:
1, 13, 14,[...],19, 2, 20, 21, 22, 23, [...], 29, 3, 30, 31, 32,[...],39, 4, 41, 42,[...], 53
where I have bolded the results which seem odd. Im guessing these values are the quarters? I am however using Weeks as my Grouping variable.
EDIT
Following Mike Honey I figured that:
WITH SET LAST52WEEKS AS
{STRTOMEMBER("[Dim Date].[Date].&[1]&[2017-01-29]").Parent.Lag(52)
:
STRTOMEMBER("[Dim Date].[Date].&[1]&[2017-01-29]").parent}
Select {[Measures].[Quantity]} ON 0,
{Last52Weeks} ON 1
FROM (
Select {
[Dim Store2].[Store Key].&[1024]
} on columns
from [DSV_FactStoreSales 1])
ought to work, but it simply returned that Quantity was (null). Why isn't this equivalent to the other Query I wrote, but based off of Date rather than week?
EDIT
I also noted that the graph I am creating has week 52 to the utmost right, whereas it is supposed to have week 4 at the utmost right.
EDIT
EDIT
Edited the Query to become:
WITH SET LAST52WEEKS AS
{STRTOMEMBER("[Dim Date].[Hierarchy].&[2017 W4]").Lag(52):STRTOMEMBER("[Dim Date].[Hierarchy].&[2017 W4]")}
Select {[Measures].[Quantity]} ON 0,
{(Last52Weeks,[Dim Store2].[Store Name].Allmembers)} ON 1
from [DSV_FactStoreSales 1]
where Hierarchy is an Attribute Hierarchy with the values 2010 W1,...., 2018 W52.
But this yields me an output:
2016 W40 Store1 300
2016 W40 Store2 400
...
2017 W39 Store1 400
where I would expect the output to be:
2016 W4 Store1 300
2016 W4 Store2 400
...
2017 W4 Store1 400
Any ideas? It is just an hierarchy with one attribute, Week Name (I've tried the Query with both using [Dim Date].[Hierarchy].[Week Name].&[2017 W4] and [Dim date].[Hierarchy].&[2017 W4], both with the same output.
EDIT (very close now!)
There are two issues I can see with your current chart. One is that your week numbers are being treated as text, which is why the ordering has sequences like 19, 2, 20. The other is that it isn't distinguishing where the week numbers for one year ends and another year starts.
I'm not familiar with mdx. I'm hoping you're able to make a simple dataset that is purely a list of sales with dates. For my solution, I used an Oracle query like:
SELECT date SALEDATE, ID FROM sales
WHERE date BETWEEN '28-MAR-2016' AND '28-JAN-2017'
With a new chart, use [Count(ID)] for the values. It then needs two category groups, first one for the year and then one for the week number. You can use expressions to get these from a date field. For the first category group, set Group on: and Label as
=DatePart(DateInterval.Year, Fields!SALEDATE.Value)
and for the second, set Group on: and Label as
=DatePart(DateInterval.WeekOfYear, Fields!SALEDATE.Value)
To then hide the columns with under 400 sales, right-click the second category group (the weeks one) and add a filter: [Count(ID)] (integer) > 400.
Even if your dataset is different from the raw data approach I'm using, hopefully this will steer you in the right direction.
Right click on the x-axis and choose "Horizontal Axis Properties". Under Axis Options change the Interval value from Auto to 1.

How can i Make This Type SSRS

I have a table in data base which has column MonthNo ,Year ,MonthValue ,AvgYTD and it has values in
1 ROW... 1 , 2010 , 2.3 , 4.0 AND
2 ROW... 2, 2010, 3.3 ,5.0 AND
3 ROW.. 3, 2010, 3.3, 7.9
AND I want output in my SSRS.....
WHEN I SELECT MONTH MARCH USING PARAMETER THEN OUTPUT WILL BE....A TABLE AND IT HAS COLUMN
JAN , FEB , MARCH , AVGYTD and values in row are ..
2.3 ,3.3, 4.3, 7.9
Updates
i am using sql server 2005 and 7.9 is th AvgYTD Value comes from table for selected month march....
i want ...if i select month march then output will be show month value of jan,feb and march and AvgYTD value for only selected month..
thanks,
Use a matrix, and if SQL 2005, use the InScope function to be able to tell if you're in the SubTotal column. In SQL 2008 you can just put a column in there for the appropriate YTD value.
Edit, to explain it more thoroughly:
Put a Matrix in the report. Use a column group on Year, MonthNo. By default that group will be called matrix1_ColumnGroup1 (or something like that - go to Edit Group to set it to something better). Put a row group on whatever causes a second row to appear.
In the Cell part of the Matrix, use an expression like:
=IIF(InScope("matrix1_ColumnGroup1"), First(Fields!MonthValue.Value), Last(Fields!AvgYTD.Value))