I am trying to implement conditional split component in my SSIS package. I need to split the records based on the year. I need to extract data for the last 5 years and need to split it before i dump it to the destination
periodenddate is datetime field. I need to extract the year part from that field and compare it against the actual year as mentioned in the expression. I am getting an error for invalid expression. Could somebody tell me where am i going wrong
The expression i am using is for eg
periodEndDate == YEAR(GETDATE())
Please find the error attached
Second error
Third error
If you want the year number from one year ago, you need to use:
YEAR([periodenddate]) = YEAR(GETDATE()) - 1
YEAR([periodenddate]) = YEAR(GETDATE()) - 2
etc.
Having the "-1" inside the parentheses for the Year() function will give you the wrong answer at the very least.
Note that you got different errors with each version of your code:
The first image shows a failure to find a field due to SSIS being case sensitive
The second image shows a failure due to comparing a datetimestamp to an integer
The third image shows an error with the expression "GETDATE() - 1", which is on a different conditional expression component than the first two images.
Related
I'm working on a simple RDBMS project. My database contains work hours per day of each employee. I have to calculate work hours of complete month. It is not a problem. But I have a problem, here it goes, each workday field contains either number of work hours or it may contain text such as if the employee was absent (symbol "A") for a particular day or it may contain symbol ("H") for holiday etc. Now my task is to calculate the 30 day work hours and exclude any symbol. But obviously the approach I am using will get me "Data Type Mismatch Error." So any body got any solution or any suggestion please. Thanks in advance!
I tried to use sum formula with NZ function, it doesn't work. Also tried Query with the same error.
Use Val:
TrueHours: Val(Nz([YourHourTextFieldName]))
That will return 0 (zero) for non-numeric entries, and that allows you to sum the values.
Im trying to find the days gap between two dates using DateDiff function.
I have 2 datasets defined. If companycode is 'AB' then from one dataset else from another dataset I retrieve data.
Here is my expression. When I change to preview mode, it shows redmark to the first First(Fields!PeriodFrom.Value line. Why? (after generating report that field shows #Error
What Im doing wrong here?
=IIF(Parameters!CompanyCode.Value="AB",
DateDiff("d",First(Fields!PeriodFrom.Value, "ABReportData"), First(Fields!PeriodTo.Value, "ABReportData")),
DateDiff("d",First(Fields!PeriodFrom.Value, "XYReportData"), First(Fields!PeriodTo.Value, "XYReportData")))
I think there are two possible scenarios. First one is the expression
=First(Fields!PeriodFrom.Value, "ABReportData")
doesnt return a value. Add a column with this expression and check if you get a value.
If the value is correct, make sure that the DateDiff() function gets a date:
=IIF(Parameters!CompanyCode.Value="AB",
DateDiff("d",
CDate(First(Fields!PeriodFrom.Value, "ABReportData")),
CDate(First(Fields!PeriodTo.Value, "ABReportData"))
),
DateDiff("d",
CDate(First(Fields!PeriodFrom.Value, "XYReportData")),
CDate(First(Fields!PeriodTo.Value, "XYReportData"))
)
)
I would like to display plan and fact cumulative data series in a dashboard with a bar and line combined chart and a table next to each other using Power BI Version: 2.59.5135.781 64-bit (2018. June) edition.
My DAX formula looks like this:
CUMULATIVE_FACT = CALCULATE(
SUM('FACT_TABLE'[FACT_VALUE]);
FILTER(
ALL('DATES');
'DATES'[YEAR]=MAX('DATES'[YEAR]) &&
'DATES'[DATE]<=MAX('DATES'[DATE])
)
)
Which works fine and gives a result as such (bars displayed as TÉNY refer to cumulative fact)
The cumulative plan (line referred to as TERV) series is identical to this but with plan figures. Also you can change the year so the aggregation only runs for the current year.
However, I would like to display either null (blank) or zero values for the fact series after a certain date which is given as a parameter. This parameter value is stored in a table with a single column and single row in a date type value.
So I modified my formula as such
CUMULATIVE_FACT = IF(VALUES('DATES'[DATE])<= MAX(PARAMETER_TABLE[PARAMETER_DATE]);
CALCULATE(
SUM('FACT_TABLE'[FACT_VALUE]);
FILTER(
ALL('DATES');
'DATES'[YEAR]=MAX('DATES'[YEAR]) &&
'DATES'[DATE]<=MAX('DATES'[DATE])
)
); 0)
The formula works fine for the chart but my table visual gives an error.
So the chart looks okay, perfectly the way I would like to display it, but the table gives back a 'A table of multiple values was supplied where a single value was expected' error message
Error message:
The column referred to in the message is basically the CUMULATIVE_FACT measure, I just changed it for ease of understanding. I tried with BLANK() instead of 0, but it looks the same.
No idea why it is not working with the table visual. Any ideas?
The problem is coming from this piece:
VALUES('DATES'[DATE])
This returns all values in the current filter context, not just a single one. That's why you're getting
A table of multiple values was supplied where a single value was expected
when you try to compare it to MAX(PARAMETER_TABLE[PARAMETER_DATE].
It works in the chart since VALUES('DATES'[DATE]) is always a single value that corresponds to the month on the axis, whereas the table has a total line that encompasses multiple months.
I think if you just turned off the total line, it would be OK. Otherwise, change VALUES('DATES'[DATE]) to an expression that returns a single date in the way you want. For example, MAX('DATES'[DATE]) might work.
I cannot work out why these Total expressions don't work...
I am trying to add any cells that have a date later than today, with any cells that have "Not Reqd", and then divide that by the number of rows, to get a percentage.
All I'm getting is #Error.
These are the expressions I've tried:
=SUM(IIf(Fields!Jetter_Trng.Value >Today OR
Fields!Jetter_Trng.Value = "Not Reqd",1,0)))/(Count(Fields!Jetter_Trng.Value)
and
=Count(IIf(Fields!Jetter_Trng.Value >Today OR
Fields!Jetter_Trng.Value = "Not Reqd",1,Nothing)))/(Count(Fields!Jetter_Trng.Value)
The "Not Reqd" string has come from an expression that changes a date (01/01/1950) to "Not Reqd". Maybe this is messing things up:
=iif(Fields!Jetter_Trng.Value = "01/01/1950", "Not Reqd", Fields!Jetter_Trng.Value)
The current working expression (not looking for "Not Reqd") is:
=COUNT(IIF(Fields!Jetter_Trng.Value>Today,1,Nothing)))/(Count(Fields!Name.Value))
I'm a bit lost...
A couple of notes on your expression as it stands at present
Jetter_Trng appears to be a string representing either a date or “Not Reqd”. You can’t compare strings to dates without casting them to a date type first using CDATE()
The number of braces (( and )) do not match
The root of your problem though is that you are using Jetter_Trng to return either a Date, or the value “Not Reqd”.
When SSRS attempts to evaluate an expression it does it all at the same time. It doesn’t follow a path to find the answer, and ignore other paths. Therefore, when you are attempting to compare
Fields!Jetter_Trng.Value >Today
This is comparing a string to a date, and throwing the error, as this mean nothing
"Not Reqd" > Today
You won’t be able to do all that you want to using only one Field of type string.
Your options are to
Use two fields – the date and a flag indicating not required, or
Use one field – but have an “invalid date” (01/01/2100 perhaps) that you could then treat as the “Not Reqd” value, and check if the current date is less than that (which it always will be)
Using the second option here you could then use the following expression to create the desired calculation
=sum(iif(CDate(Fields!Jetter_Trng.Value) > Today, 1, 0)) /
Count(Fields!Jetter_Trng.Value)
Which would evaluate this dataset as follows
I am currently trying to build a report that pulls all the created bugs today into a report. The fields I am using are 'Work Item.Created Date' and 'Work Item Count'. What I am getting information back. The problem is I can't seem to get the report to only show items for today. I have set a filter of:
Expression: [Created_Date] as Text (What I can not change)
Operator: =
Value: =Today()
When I run this I get the following error:
The processing of FilterExpression for the dataset ‘DataSet1’ cannot be performed. Cannot compare data of types System.String and System.DateTime. Please check the data type returned by the FilterExpression. (rsComparisonTypeError)
I have tried using the following as the Vale entry:
=Today().Parse("12/04/2009").ToString()
I don't get an error but I am not 100% sure if it is right, any help would be much appreciated
If you want a list of bugs then you should connect to the Data Warehouse (tfs_warehouse) rather than the Cube (tfs_analysis) and pull a list from the WorkItems table.
This should be easyer to query. Additionally I do not believe that "today()" is processed as you expect. You need to get todays date and pass it in rather than use "today()".