switch and/or iff function in SSRS. How to use both or any for two given columns - ssrs-2012

How to use =SWITCH & IIF condition to change color in SSRS if the condition is met. I have two columns “ScheduledDate” (which is date/time), and Activity(which is text format). I want to change the color of Activity (which has the output as Complete, Current, Overdue), if the ScheduledDate is greater than today’s date, then I want to change the Overdue data in Column Activity to RED.
Should using Switch would be good or IIF. How? Can anyone please give an example?
Appreciate any help on this one.
Thanks,
Niki

In this scenario, if you only need set RED without setting multiple color for fields, it's better to use IIF(). Base on your condition, try the expression below:
=IIF(Fields!ScheduleDate.Value>Now() and Fields!Activity.Value="Overdue",Red,Black)

I think I figured it out. It works. Thanks for your help.
=iif(Fields!ScheduleDate.Value > Now() and Fields!Activity.Value ="Cancelled","Red",
iif(Fields!ScheduleDate.Value < Now() and Fields!Activity.Value ="Created","Green","Red"))

Related

Confirm my attempt at converting Crystal reports selection criteria to Oracle SQL

I have to create selection criteria for an Oracle SQL query based on a snippet from Crystal Reports.
I have no experience with Crystal reports so I have been trying to figure it out searching the web, but seem to be just wasting my time - Could not find anything helpful for this kind of task on the web.
This is the selection criteria that was provided:
{MATL_USED_VW.MAT_ID} = {?Material ID} and
{#Use Date} in {?Previous Use}
//#UseDate = Date({MATERIAL_ACTIVITIES.MA_END})
The column data types are all date columns except for the numeric MAT_ID column
I think this would equate to the following:
where matl_used_vw.mat_id = :Material_id
and use_date in (:previous_use, :usedate)
This is just a swag based on assumptions.
Here's my assumptions on the symbols:
? - probably is a parameter or prompt for input
# - has something to do with formulas
// - is continuation of previous line
{} - encloses an object (text, date number or whatever)
I'm not sure of anything here, it's all just a guess.
If anyone could shed some light on this, I would really appreciate it!
Thanks for the help on this!
Here's the answer in case some other schmuck unfamiliar with Crystal reports needs a similar answer:
# is a Formula. In this case, to convert text to date.
? is a Parameter In this case it represents a range
// is a remark. Same as # or ‘ in other languages.
{} - encloses an object (text, date number or whatever)

User facing date field granularity control

I'm trying to give my users the option to select the date field granularity of their choice, such as day, week, month or year. This is normally controlled on each graph in the menu show below but this isn't available in a published dashboard:
My first idea was to create a calculated field that truncates my desired date based on a parameter that I expose through a control. This would like something like this, truncDate(${intervalParameter}, {dateColumn}). The problem with this is that the first argument of the truncDate function must one of valid string literals and will throw an error before saving if it isn't.
Does anyone know of any other ways of achieving this? Or maybe some sneaky way of getting around the error?
I figured out a work around using ifElse.
ifElse(
${intervalParameter} = 'Day', truncDate("DD", {dateColumn}),
${intervalParameter} = 'Week', truncDate("WK", {dateColumn}),
${intervalParameter} = 'Month', truncDate("MM", {dateColumn}),
truncDate("DD", {dateColumn})
)
There might be better solutions out there but this is what I've come up with.

Google Sheets/Excel: Checking if a time falls within a range

I'm trying to find a way to see if I can find a way to determine if a time that I stipulate falls between two other times. For example:
Start End
11:33:48 11:53:48
12:20:22 12:38:21
12:39:27 13:00:09
14:16:23 14:20:49
14:20:54 14:22:56
Then, I want to check if a cell (here the value of 12:50 in cell E30) falls between ANY two values in a range in THE SAME ROW. For me, I can get the obvious way to check for this in one row, and this simple version totally works:
=If(AND(E30>A4,E30<B4), "TRUE", "FALSE")
However, I want to check if that number falls within ANY of the values within the ROWS above cells in a range, and I can't get that to work. For example, I tried this and it didn't work:
=If(AND(E30>A:A,E30<B:B), "TRUE", "FALSE")
I also tried a simple countif variation but that didn't do it either:
=COUNTIFS(A:A,">"&E30,B:B,"<"&E30)
Any advice on how to adjust one of these formulas to get it to work?
Try switching the angle brackets around:
=COUNTIFS(A:A,"<"&E30,B:B,">"&E30)
I think this should work for the above data set -
=IF((FILTER(A2:B6, D2>A2:A6,D2<B2:B6)),TRUE,FALSE)
This will give you if there is any match or not.
For the number of rows count that match -
=ROWS((FILTER(A2:B6, D2>A2:A6,D2<B2:B6)))
Alomsot =IF(Q2>R2,IF(AND($X$16>HOUR(Q2),$X$16<(HOUR(R2)+12)),1,0),IF(AND(HOUR($X$14)>=HOUR(Q2),HOUR($X$14)<=HOUR(R2)),1,0))

Use condition in powerpivot (DAX)

My problem is that I can't get the IF condition to work in powerpivot (using DAX).
According to manual the syntax is:
IF(logical_test>,, value_if_false) where I can omitt the "value if false" if i want.
I have a lot of columns and I try to make a new one based on condition from another column.
What I tried is =IF([TimeTypeCode]="400", [WorkingHours]) and that doesn't work. What I want my condition to do is that if [TimeType] is equal to 400, then i want to put the value from [WorkingHours] in my new column. How can i do this?
from what I see here the problem is the ="400", the "" you used tell dax thats a string type and you are trying to use it as a numeric value.
Try using
IF([TimeTypeCode]=400, [WorkingHours])
instead,
Cheers!

Multiple Conditions In Excel

I entered the below formula into excel. When I copy the formula down for the rest of my sheet, it gives the "eligible" value to all fields even when the J field has no data to pull from. What am I missing?
=IF(J3<=40,"Eligible",IF(AND(J3<=30, J3>=39.99), "Particially","No"))
Blank is interpreted as zero, so J<=40 will be true. You probably need to put an IsNumber check in there too.
=IF(AND(J3<=40,ISNUMBER(J3)),"Eligible",....
EDIT: based on your comment, you can simplify this by reversing the logic, and you don't need an and clause.
=IF(J1<30,"no",IF(J1<40,"partial","eligible"))
I think logic is wrong.
Try this (included remark by John Barça):
=IF(ISNUMBER(J3),IF(J3<30,"Eligible",IF(AND(3<=39.99,J3=30),"Partially","no")),"Not a number")
Or please describe what you want to get.

Resources