I have a report with two datasets.
The two relevant columns in the first dateset (Test1) are:
Name
Effective_Date
The relevant columns in the second dataset (Test2) are:
Name
Date_From
Date_To
Result (Which is always the value 1)
The Main-Tablix where I put in the expression works on the first Dataset "Test1". In my field I want the output of the column Result from Dataset 2 "Test", if the name matches and also if the Effect_Date from "Test1" is between Date_from and Date_to from "Test2".
Is there any way to check those 2 conditions in a LookUp? Currently I'm only able to check one condition:
=Lookup(
Fields!Name.Value,
Fields!Name.Value,
Fields!Result.Value, "Test2")
Thanks in advance for your help!
Related
I have a table named as energymeter which have 3 columns named as Date, Name, Value.
I want a result of highest value of day- minimum value of day of each day in specified time period of individual parameter (Name) into 3 separate columns.
Here is my table structure
And i am getting result for single parameter as i wish using query
select Date(Date) as Date,
Max(Value) - Min(Value) as Value ,
Name
from energy_meter.energy_meter
WHERE Name ='Energy_Meters\[1\].Total_active_energy_kWh'
And DATE(Date) between '2022-10-01' and '2022-10-13'
group by DATE(Date)
and getting result as below
and i want result should look like below for all 3 parameters
Community help is needed.
Thanks
I have a parameter date from dataset date:
Sample of data
Key
Month
Year
Row num
20210131
January
2021
3
20201231
December
2020
2
20201130
November
2020
1
I need to do an expression that returns the previous of selected value for example when a user selects January 2021(date parameter) it will return December 2020 in expression in text box.
I try previous(first(fields! Month_year. Value, "group name")) but it returns error, is there any way to resolve it?
I would suggest that you extend the dataset query to include the previous value against each row.
Assuming you dataset query is called DataSet1 and uses a table called 'myTable' then something like this (I changed the sample column name from Key to KeyID to avoid keyword problems).
SELECT *
, LAG(KeyID) OVER(ORDER BY RowNum) as PreviousMonthKeyID
FROM myTable
NOTE: This assumes row number is always in the correct order, if not then you could change this to order by KeyID.
You can then use a LOOKUP() to find the correct value, so if your parameter is called selectedDate and it's value is set to the KeyID column, use something like
=LOOKUP(Parameters!selectDate.Value, Fields!KeyID.Value, Fields!PreviousMonthKey.Value, "DataSet1")
This reads "get the value in selectdDate, find this value in the column KeyID in the dataset called DataSet1 and return the value found in the column called PreviousMonthKeyID"
I am trying to create an RDL file and I need a tablix to appear in the following format.
This is how I want the results to look
The values that are in bold are hard coded values. This is how the output from the SELECT statement in the datasets looks
SQL Output
I don't know how to make the values that output from the database match with the hard coded values in the RDL file. The 'Day' field represents a day in the month and the 'Num' field represents the number of sales that were on the day. The above example shows that on the first day of the month, there were 100 sales made. I need the tablix to output in that specific format.
If the day isn't in the SQL output (no sales made that day), I want it to output blank and/or 0.
Any idea how this could be accomplished?
Use a CTE to create rows for each day you need and then join your results on. A starting point for you CTE could be:
;WITH nums AS
(SELECT 1 AS value
UNION ALL
SELECT value + 1 AS value
FROM nums
WHERE nums.value <= 30)
SELECT *
FROM nums
You'll probably then want to modify the total days based on the month you are viewing.
You can do this using lookups, but you would need to hard code a lookup in each cell. e.g. for day 1
=lookup(cint(1),Fields!Day.Value,Fields!Num.Value,"Dataset1")
A faster way would be to create a tablix on the dataset filtered on the first ten days:
=Switch(
Fields!DAY.Value <= 10 and Fields!DAY.Value >=1,"Include",
True,"Exclude"
)
Create a row group on days, then create a column with day and num, and columns with Fields!DAY.Value+10 and Fields!DAY.Value+20 with the following lookups:
=lookup(Fields!DAY.Value+10,Fields!DAY.Value,Fields!NUM.Value,"DataSet1")
=lookup(Fields!DAY.Value+20,Fields!DAY.Value,Fields!NUM.Value,"DataSet1")
So I have an SSSRS REPORT with 2 data sets. If the day of the week is Friday I need to show the data in dataset 2 otherwise to use dataset 1. How can I accomplish this? is there a built in expression or function to do this???
You can't set DataSetName property at runtime, but you can select the data you want to return in your dataset based on the week day.
IF DATENAME(WEEKDAY,GETDATE()) = 'Friday'
select categoryDS1 Category, salesDS1 Sales from tableDS1
ELSE
select categoryDS2 Category, salesDS2 Sales from tableDS2
This will work if both SELECT statements have the same columns name
and types.
Let me know if this helps.
You can place a copy of both reports in the report and simply set the visibility for the one you want to show. The expression for the Visibility property for DataSet1 would be:
=IIf(WeekdayName(Weekday(Today)) = "Friday", True, False)
Swap the result for DataSet2.
I have report that based on the Createdon date group and its amount on that.so I have created group on createdon in SSRS Report and also put sorting based on createdon date.The data is like this
Date Total Amount
6-22-2013 500
5-23-2013 500
5-24-2013 1000
5-28-2013 200
6-21-2013 300
6-23-2013 400
I shown you some of the data.same way that are lots of data and every data shown as expected.but expect the one data as you can see the first record regarding 6-22-2013.It should be come second last based on group as i sort group based on Createdon date.I feel that this bug is from Microsoft.However I am not sure but how can only one record created this problem?Any help from anybody would be appreciated.
Can you check if the date field is actually date. I mean if it is text then it will be sorted arbitrarly .
Try sorting by below expressions
=day(Fields!createdon.Value)-- 1st sort expression
=month(Fields!createdon.Value)--2nd sort expression
=Year(Fields!createdon.Value)-- 3rd sort expression