Nesting IIF in SSRS

I have the expression below running as my BG colour
=IIF(RowNumber(Nothing) MOD 2 =1,"#FCDFFF","Transparent")
But there are columns identified for additional formatting. For example, I want to colour a particular row base on a condition but knowing that I already have the above expression running across all rows how do I make that a reality?
Thank you.
Zionlite

You can also use a nested iif
=Iif(Fields!Value.Value
> 100,
"Red", iif(RowNumber(Nothing) MOD
2 =1,
"Green", Nothing))

Similar Messages

  • Nested IIF in SSRS 2012

    I am trying to set 2 hidden conditions on a row that will show alternate numbered rows (all even #), and also hide any rows that have an answer of '0' or "".
    I have tried various variations of the IIF statement.  Can someone please help me with getting this to display correctly?
    =IIF((rownumber(nothing) mod 2)=0, false, true) And IIF(Fields!PrimaryAnswer.Value <> ""
    OR (Fields!PrimaryAnswer.Value <> "0"), false, true)
    (this does not give me either condition I am looking for)

    Hi SSRSNewUser,
    According to your description, you want to hide the even rows and rows contains '0' or "" value for data field answer. Right?
    In this scenario, the reason why the expression is not working because the logic is not correct. In expression, "AND" has higher priority than "OR". So the logic in your expression is (even rows and answer ="") OR (answer="0"). For your requirement, the
    expression should be like:
    =IIF((rownumber(nothing) mod 2)=0, false, true) OR IIF(Fields!PrimaryAnswer.Value <> ""
    OR (Fields!PrimaryAnswer.Value <> "0"), false, true)
    This expression will hide the even rows first and then hide the rows with "0" or "". If you want to hide the rows with "0" or "" first and then hide the even rows in rest rows, we suggest you use filters. Filters will be executed based on sequence.
    One important thing is, there is "AND" logic between filters, so you need to put "OR" logic together into one filter expression.
    Reference:
    FAQ: How do I implement OR logic or complicated logics for filters in a  SSRS report?
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Can nested IIf be created in custom workflow (in Designer)?

    I need to explore building a custom workflow in Designer that will allow me to update a hidden field in the list.  Is it possible for me to recreate the nested IIf statement I have written below?  I'm not seeing how to do get an AND operator in
    the workflow designer, nor the nested concept.
    TypeOfChange: IIf([status]="active",
    IIf([program type]="p", "Primaries Approved",
    IIf([program type]="o", "Options Approved",
    IIf([program type]="R" Or [award]="AAS-T", "AAS-T Programs Registered",
    IIf([apprentice]="a", "Apprenticeships Registered",
    IIf([contract]="c", "Contracts Approved",
    IIf([College Report Categories]![title]="collaborations", "Collaborations Registered",
    IIf([Indiv Program Students] is Not Null, “Individualized Programs”,
    IIf([program type]="st","ST Programs Registered")))))))),
    IIf([status]="Title changed", "Titles Changed",
    IIf([status]="removed",
    IIf([program type]="p", "Primaries Deleted",
    IIf([program type]="o", "Options Deleted",
    IIf([program type]="st", "ST Deleted"))),
    IIf([status]="Inactive",
    IIf([program type]="p", "Inactive Primaries",
    IIf([program type]="o", "Inactive Options")), 
    IIf([status]="Reinstated", "Reinstated Programs",
    IIf([status]="Pending", "Pending Requests",
    IIf([status]="NoI Review", "NoI Review Period",
    IIf([status]="Modified", "Curriculum Modifications",""))))))))
    There are no mistakes; every result tells you something of value about what you are trying to accomplish.

    Hi run4it,
    When add multiple compare conditions in workflow condition, it will show the operator AND, then you can try disigning the logic of if else branch sentenses as Andy suggested.
    Thanks,
    Daniel Yang
    Forum Support
    If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Daniel Yang
    TechNet Community Support

  • Using nested IIF expressions in an update query - is it possible?

    Hi everyone,
    I've been tasked by my manager to build a database which replicates a large, complicated Excel spreadsheet that consumes too much of our team's time and system resources. I've just about got most of it, but there is one particular required field that, in
    Excel, requires multi-layered nested If/Then formulae. I have to ask if building something similar in Access is possible. Here is the problem and the logic:
    Let us assume two established fields, Field 1 and Field 2; and then one field to be created via Update query, Field 3.
    Let us further assume that in Fields 1 and 2, there are three specific alphanumeric sequences occurring (“X1A”, “X1”, and “Z1”) that need to be identified and then called out as either “S1” or “U1” in field 3.
    If an Update Query were to be written to populate Field 3 with either “S1” or “U1” depending on one of the three alphanumeric sequences appearing in either Field 1 or Field 2, could it be written as the following expression, using the IIF and OR operators?
    And if so, is the syntax of the following expression correct?
    IIf([FIELD 1]="* X1A", "U1", OR IIf([FIELD 2]="* X1", "U1", OR IIf([FIELD 2]="* Z1", "U1", OR IIf([FIELD 1]="* X1", "U1", OR IIf([FIELD 1]="* Z1", "U1", "S1")))))
    Any help, critiques, or guidance would be appreciated.

    IMHO, a main consideration when "migrating" from Excel to Access is that a relational database is fundamentally different from a spreadsheet (although there can be much overlap).  In Excel, calculated values are "live" (unless you paste the values only
    into some other cells).  To replicate this "live" quality in Access, you can use a query with a calculation to display (not create or update) Field 3 in your case; Field 3 really wouldn't be a field, just a representation (query, form, report) or snapshot
    (export, print).  One reason for this is to avoid conflicts and redundancy.  In other words, if Field 3 is based solely on Fields 1 & 2 and some rule, then usually there is no need to waste disk space to store Field 3 and you don't risk Field
    3 being wrong as in the case when the rule changes.
    So here are a couple of options.
    1) Create view only query to display Field 3.  In query design view, enter the following where you would normally select a field:
    [FIELD 3]: IIf([FIELD 1]="* X1A", "U1", IIf([FIELD 2]="* X1", "U1", IIf([FIELD 2]="* Z1", "U1", IIf([FIELD 1]="* X1", "U1", IIf([FIELD 1]="* Z1", "U1", "S1")))))
    I assume you literally mean the asterisk character and are not trying to invoke a wildcard for the LIKE operator.
    There are other ways of doing this (e.g. with the LIKE operator or multiple queries and UNION), but I leave that up to you to explore.
    2) Actually update the value of FIELD 3 in a table.  Create two update queries and use your rules as conditions (i.e. the criteria in the bottom of query design).
    a) Update query 1 (run first): set [FIELD 3] = "U1" where [FIELD 1] = "* X1A" OR [FIELD 1] = "* X1" OR [FIELD 1] = "* Z1" OR [FIELD 2] = "* X1" OR [FIELD 2] = "* Z1"
    b) Update query 2 (run after): set [FIELD 3] = "S1" where [FIELD 3] is null
    Again, there are other ways of doing this such as setting the default value of [FIELD 3] in the table to "S1" and just running update query 1.
    Good luck.

  • IIF In SSRS With Opposite Of = For A List

    I am trying to build a Expression using IIF with the opposite of this in a calculated field:
    =IIF((Fields!DEPARTMENT_CODE.Value = "22700") OR (Fields!DEPARTMENT_CODE.Value = "22800") OR (Fields!DEPARTMENT_CODE.Value = "22900") OR (Fields!DEPARTMENT_CODE.Value = "23000") OR (Fields!DEPARTMENT_CODE.Value = "2350")
    OR (Fields!DEPARTMENT_CODE.Value = "23800") OR (Fields!DEPARTMENT_CODE.Value = "23900") OR (Fields!DEPARTMENT_CODE.Value = "24000") OR (Fields!DEPARTMENT_CODE.Value = "24100") OR (Fields!DEPARTMENT_CODE.Value = "24200")
    OR (Fields!DEPARTMENT_CODE.Value = "24300"),1,0)
    I have tried <>, AND, AND NOT, and XOR which all seem to yield the same results.  Any suggestions would be greatly appreciated!
    Thanks in advance! Brett

    Hi Brett,
    To sum it up, The IIF() statement has the following format:
    =IIF( Expression to evaluate, what-to-do when the expression is true, what-to-do when the expression is false )
    Parameter1: It should be a Boolean expression.
    Paremeter2: This value will return when Expression is true.
    Paremeter3: This value will return when Expression is false.
    So in the Calculated Field 1, we can use the expression below to achieve your requirement:
    =IIF((Fields!DEPARTMENT_CODE.Value = "22700") OR (Fields!DEPARTMENT_CODE.Value = "22800") OR (Fields!DEPARTMENT_CODE.Value = "22900") OR (Fields!DEPARTMENT_CODE.Value = "23000") OR (Fields!DEPARTMENT_CODE.Value = "23500") OR (Fields!DEPARTMENT_CODE.Value =
    "23800") OR (Fields!DEPARTMENT_CODE.Value = "23900") OR (Fields!DEPARTMENT_CODE.Value = "24000") OR (Fields!DEPARTMENT_CODE.Value = "24100") OR (Fields!DEPARTMENT_CODE.Value = "24200") OR (Fields!DEPARTMENT_CODE.Value = "24300"),1,0)
    In the Calculated Field 2, we can use the expression below to achieve your requirement:
    =IIF((Fields!DEPARTMENT_CODE.Value = "22700") OR (Fields!DEPARTMENT_CODE.Value = "22800") OR (Fields!DEPARTMENT_CODE.Value = "22900") OR (Fields!DEPARTMENT_CODE.Value = "23000") OR (Fields!DEPARTMENT_CODE.Value = "23500") OR (Fields!DEPARTMENT_CODE.Value =
    "23800") OR (Fields!DEPARTMENT_CODE.Value = "23900") OR (Fields!DEPARTMENT_CODE.Value = "24000") OR (Fields!DEPARTMENT_CODE.Value = "24100") OR (Fields!DEPARTMENT_CODE.Value = "24200") OR (Fields!DEPARTMENT_CODE.Value = "24300"),0,1)
    If you have any other questions, please feel free to let me know.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Multiplying 2 values based on an If statement in SSRS reports

    I am working on a pretty complicated report, and I am unable to get the values to multiply correctly on one line.  The expression is simple, if the value in textbox293 is greater then the value in textbox294 then multiply textbox293 by textbox289 else
    multiply textbox294 by textbox289.  
    In SSRS terms IIF(textbox293.value > textbox294.value, textbox293.value * textbox289.value, textbox294.value * textbox289.value)
    I am using the actual formulas that I used to get the values, they have a nested IIF statement to return 0.00 if the value is less < 0.  I am also rounding to 6 decimal places on 1 value to ensure I get the correct value out to 4 decimal places.
    I have checked all of the value on the report up to this point are correct, and are displaying correctly.  I have broken apart my IIF statement to make it easier to read: 
    =IIF(IIF((Sum(Fields!RSR_MIN_2.Value, "Revenue") + IIF((Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value, "End_Fund_Balance"))
    * (Sum(Fields!RGF_MIN_2.Value, "Revenue") / First(Fields!RGF_MIN_2.Value, "Rev_Code5899"))< 0, 0.00, (Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value,
    "End_Fund_Balance")) * (round(Sum(Fields!RGF_MIN_2.Value, "Revenue") / First(Fields!RGF_MIN_2.Value, "Rev_Code5899"),6))))/(First(Fields!WADA2011_1.Value, "Second_Year_Preceeding_WADA")) < 0, 0.00, (Sum(Fields!RSR_MIN_2.Value,
    "Revenue") + IIF((Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value, "End_Fund_Balance")) * (Sum(Fields!RGF_MIN_2.Value, "Revenue")
    / First(Fields!RGF_MIN_2.Value, "Rev_Code5899"))< 0, 0.00, (Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value, "End_Fund_Balance"))
    * (round(Sum(Fields!RGF_MIN_2.Value, "Revenue") / First(Fields!RGF_MIN_2.Value, "Rev_Code5899"),6))))/(First(Fields!WADA2011_1.Value, "Second_Year_Preceeding_WADA"))) 
    >
     =IIF((Sum(Fields!RSR_MIN_1.Value, "Revenue") + IIF((Sum(Fields!SR_MINUS_1.Value, "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(Sum(Fields!RGF_MIN_1.Value,
    "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"))< 0, 0.00, (Sum(Fields!SR_MINUS_1.Value, "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(round(Sum(Fields!RGF_MIN_1.Value,
    "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"),6)))) / (First(Fields!WADA2012_1.Value, "Second_Year_Preceeding_WADA")) < 0, 0.00, (Sum(Fields!RSR_MIN_1.Value, "Revenue") + IIF((Sum(Fields!SR_MINUS_1.Value,
    "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(Sum(Fields!RGF_MIN_1.Value, "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"))<
    0, 0.00, (Sum(Fields!SR_MINUS_1.Value, "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(round(Sum(Fields!RGF_MIN_1.Value, "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"),6))))
    / (First(Fields!WADA2012_1.Value, "Second_Year_Preceeding_WADA")))
    IIF((Sum(Fields!RSR_MIN_2.Value, "Revenue") + IIF((Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value, "End_Fund_Balance")) * (Sum(Fields!RGF_MIN_2.Value,
    "Revenue") / First(Fields!RGF_MIN_2.Value, "Rev_Code5899"))< 0, 0.00, (Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value, "End_Fund_Balance"))
    * (round(Sum(Fields!RGF_MIN_2.Value, "Revenue") / First(Fields!RGF_MIN_2.Value, "Rev_Code5899"),6))))/(First(Fields!WADA2011_1.Value, "Second_Year_Preceeding_WADA")) < 0, 0.00, (Sum(Fields!RSR_MIN_2.Value, "Revenue")
    + IIF((Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value, "End_Fund_Balance")) * (Sum(Fields!RGF_MIN_2.Value, "Revenue") / First(Fields!RGF_MIN_2.Value,
    "Rev_Code5899"))< 0, 0.00, (Sum(Fields!SR_Minus_2.Value, "Certificated_Exp") - First(Fields!RSR_MIN_2.Value, "Rev_Code5899") - First(Fields!End_Fund_min2.Value, "End_Fund_Balance")) * (round(Sum(Fields!RGF_MIN_2.Value,
    "Revenue") / First(Fields!RGF_MIN_2.Value, "Rev_Code5899"),6))))/(First(Fields!WADA2011_1.Value, "Second_Year_Preceeding_WADA"))) * (first(Fields!WADA2013_1.Value,"Second_Year_Preceeding_WADA"))
    IIF((Sum(Fields!RSR_MIN_1.Value, "Revenue") + IIF((Sum(Fields!SR_MINUS_1.Value, "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(Sum(Fields!RGF_MIN_1.Value,
    "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"))< 0, 0.00, (Sum(Fields!SR_MINUS_1.Value, "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(round(Sum(Fields!RGF_MIN_1.Value,
    "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"),6)))) / (First(Fields!WADA2012_1.Value, "Second_Year_Preceeding_WADA")) < 0, 0.00, (Sum(Fields!RSR_MIN_1.Value, "Revenue") + IIF((Sum(Fields!SR_MINUS_1.Value,
    "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(Sum(Fields!RGF_MIN_1.Value, "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"))<
    0, 0.00, (Sum(Fields!SR_MINUS_1.Value, "Certificated_Exp")-first(Fields!RSR_MIN_1.Value,"Rev_Code5899")-first(Fields!End_FundMinus1.Value,"End_Fund_Balance"))*(round(Sum(Fields!RGF_MIN_1.Value, "Revenue")/first(Fields!RGF_MIN_1.value,"Rev_Code5899"),6))))
    / (First(Fields!WADA2012_1.Value, "Second_Year_Preceeding_WADA"))) * (first(Fields!WADA2013_1.Value,"Second_Year_Preceeding_WADA")))
    A screen shot of the report:
    The value in the bottom box should be: 37,080,118.75
    I have tried:
    =IIF(ReportItems!Textbox293.Value > ReportItems!Textbox294.Value, ReportItems!Textbox293.Value * ReportItems!Textbox289.Value, ReportItems!Textbox294.Value * ReportItems!Textbox289.Value) and I get a scope error.
    I have also tried 
    =IIF(CDbl(Fields!Textbox293.Value) > CDbl(Fields!Textbox294.Value), CDbl(FieldsTextbox293.Value) * CDbl(Fields!Textbox289.Value), CDbl(Fields!Textbox294.Value) * CDbl(Fields!Textbox289.Value))
    I get the same scope error, part of the problem here is that in order to get things to display correctly each row in this section of the report is a different table
    Row1 = tablix19
    Row2 = tablix20
    Row3 = tablix21
    Any help here would be great

    Hello,
    In your case, we can try to use Report Variables to resolve the issue. In SSRS, when we have a complex calculation we can create a variable in the report. Variable can be used more than once in a report. Please refer to the following steps:
    Open Report Properties dialog box.
    Click Variables in the left pane. Then, add specific variable.
    (Note: Suppose we have create two variables: textbox293, textbox294)
    After that, we can use following expression to calculate the effect:
    =IIF(Variables! textbox293.Value > Variables! textbox294.Value,
    Variables! textbox293.Value * ReportItems!Textbox289.Value,
    Variables! textbox294.Value * ReportItems!Textbox289.Value)
    Reference:
    Report and Group Variables Collections References
    If the issue is persist, please feel free to let me know.
    Regards,
    Alisa Tang
    If you have any feedback on our support, please click
    here.
    Alisa Tang
    TechNet Community Support

  • Partially Bold Text in SSRS 2005 using Expression ?

    Hi,
    I am using SSRS 2005.
    I have one requirment. I need to Partially Bold some part of Text in column.
    Below is the Example.
    Name < - -- Column in SSRS 2005 Report.
    This column contains combination of Last Name and First Name. All Database record contains Last name , while in some record our requirment is to append First Name with that.
    That is i aleady handled using Nested IIF Expression.
    Now, i want to display appended First Name in normal while all Last Name whihc is Database Field in BOLD Font.
    How is it possible ?

    Hi
    I have just saw a possible solution (well done Hentie Stassen!)
    The best solution of course is to upgrade to SQL 2008 reporting services.
    But, if you are stuck with SQL 2005, try the following:
    We know that a possible solution is to have 2 textboxes.  One for name, one for surname.  Then make the surname bold.  This works, but spacing is a big problem as we saw in other examples on this thread.  Here is the solution for the
    spacing problem:
    The idea is to have 1 textbox for the name, with lots of surname textboxes at different positions and only have 1 of these surname textboxes visible. 
    More detail:
    1. The left-most textbox is the Name field.
    2. Then have 10 or more Surname textboxes, with Bold and displaying the Surname field.  All surnames text boxes overlapping each other, but each one starting about 1cm to the right of the previous one.  The first Surname textbox starts about 1cm
    to the right of the leftmost point of the Name textbox, overlapping most of it.
    3. Now set the visibility property of each of the "Surname" textboxes.  All will be hidden by default.  Set the visibility of the 1st "surname" to true only if the lenth of the name field is less than 2.  Set the visibility
    of the 2nd "surname" to true only if the length of name =2, etc.
    Have a happy day
    Andre Maakal

  • Dashboard in SSRS Query

    Hi,
    I am new to SSRS, as I have to create on dasboard in ssrs which will cover 4-5 chart and other type of reports on single screen.
    I just want to know, is there any properties need to configure for 5 chart or i have to just drag 5 chart from tool.
    another question.
    every chart will show other data like sum of reveny by state, by country, by region like that.
    so do I have to create 5 dataset or 1 dataset is sufficient for all 5 chart.
    thanks & regards,
    Vipin jha
    Thankx & regards, Vipin jha MCP

    Hi Christof_S,
    According to your description, there is a calculated field called Deltatype in the report. If Work PrevWeek is null and Work is null, then Deltatype is 0. If Work PrevWeek in null and Work isn’t null, then Deltatype is 2. If Work PrevWeek is the same with
    Work, then Deltatype is 1, else 3. The iif function works but the performance is poor.
    According to my knowledge, the Iif function returns one of two values depending on whether the expression is true or not. When we have three or more conditions, nested IIF statements will make expression harder to read and extend, instead, we can use Switch
    function to get the same functionality. In this case, we can modify the expression like below:
    Switch
    (ISEMPTY([Measures].[Work PrevWeek]) AND ISEMPTY([Measures].[Work]),0,
    ISEMPTY([Measures].[Work PrevWeek]) AND NOT ISEMPTY([Measures].[Work]),2,
    [Measures].[Work PrevWeek] <> [Measures].[Work], 3, true, 1)
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu

  • How to handle the #error in ssrs expression

    hi 
    Please any one help me to resolve this #error ,
    I have a calculated filed in that expression i given a if condition like below 
    data of column is coming like this 0 , 0.0 
    =IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/( Fields!Column1.Value)))
    how to handle the #error 
    Please let me know any one 

    Hi deepuk23,
    According to your description, when you use the IIF() function in the report you got some error,right?
    The issue can be caused by the column1 and column2 have different datatype, I assumed that one is integer and another is float, when the Column1 is 0 or null,  because IIF() function always evaluates both the true part and the false part, even
    though it returns only one of them, it will throw out the error. 
    To resolve the issue, you should use a nested IIF() function to avoid the zero-divisor in any rate like below:
    =IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/(IIF(Fields!Column1.Value=0,1,Fields!Column1.Value))))
    For more information, please refer to this article:
    FAQ: Why does the “Attempted to divide by zero” error still happen?
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Deltatype in SSRS Query

    I have a cube with several measures like cost (bound to a calender week hierarchy) and a calculated measure representing the value from the week before (it is a calculated measure navigating in the CW-hierarchy prevmember). Same for work (Containing an integer
    value, also prevmember for the previous week)
    A query can somehow look like this:
    Document Work PrevWeek Work week Delta Work Deltatype
    ABC123 5 10 5 3
    ABC124 10 10 2
    ABC125 5 5 0 1
    I have a calculated column called "Deltatype" with this expression:
    IIF
    (ISEMPTY([Measures].[Work PrevWeek]) AND ISEMPTY([Measures].[Work]),0,
    IIF
    (ISEMPTY([Measures].[Work PrevWeek]) AND NOT ISEMPTY([Measures].[Work]),2,
    IIF
    ([Measures].[Work PrevWeek] <> [Measures].[Work], 3,1
    So 1 is unchanged, 2 is new and 3 is changed. Works pretty neat, with only one glitch: Performance! It takes ages! (If it does finish at all...)
    Does anybody know an expression that needs less performance? I have a table in which i derive the type in the report, here it is pretty fast. But I can't really use it for charts and/or grouping etc.
    Thanks a lot in advance,
    Christof!
    (Disclaimer: I've also asked this question on StackOverflow but my experience getting an answer there is not soooo good, so please forgive me!)

    Hi Christof_S,
    According to your description, there is a calculated field called Deltatype in the report. If Work PrevWeek is null and Work is null, then Deltatype is 0. If Work PrevWeek in null and Work isn’t null, then Deltatype is 2. If Work PrevWeek is the same with
    Work, then Deltatype is 1, else 3. The iif function works but the performance is poor.
    According to my knowledge, the Iif function returns one of two values depending on whether the expression is true or not. When we have three or more conditions, nested IIF statements will make expression harder to read and extend, instead, we can use Switch
    function to get the same functionality. In this case, we can modify the expression like below:
    Switch
    (ISEMPTY([Measures].[Work PrevWeek]) AND ISEMPTY([Measures].[Work]),0,
    ISEMPTY([Measures].[Work PrevWeek]) AND NOT ISEMPTY([Measures].[Work]),2,
    [Measures].[Work PrevWeek] <> [Measures].[Work], 3, true, 1)
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu

  • MDX IIF calculate Jan to Dec but do not effect Q1-Q4 and Yeartotal

    Hi All,
    I'm using the following MDX member formula to calc a version "DOP" data for Jan to Dec, but I want keep Q1-Q4 and yeartatal aggregate by themselves(Not Calculate):
    CASE
    When
    Is([Forecast],[Scenario].CurrentMember)
    Then
    CASE
    When Is([&CurrYear],[Year].CurrentMember) Then
    IIF(Count(Intersect({MemberRange([Jan],[&CurrActMonth])}, {Period.CurrentMember})) = 1,
    [Placeholder],
    ([Working] + [Placeholder]))
    When Is([&PlanYear],[Year].CurrentMember) Then ([Working] + [Placeholder])
    END
    END
    There is no syntax error. But the Q1-Q4 and Yeartotal data were calced also(copyed from other version([Working] + [Placeholder])).
    So I try another way by using nested IIF:
    CASE
    When
    Is([Forecast],[Scenario].CurrentMember)
    Then
    CASE
    When Is([&CurrYear],[Year].CurrentMember) Then
    IIF(Count(Intersect({MemberRange([Jan],[&CurrActMonth])}, {Period.CurrentMember})) = 1,
    [Placeholder],
    IIF(Count(Intersect({MemberRange([&NextMonth],[Dec])}, {Period.CurrentMember})) = 1,
    ([Working] + [Placeholder]),Missing))
    When Is([&PlanYear],[Year].CurrentMember) Then ([Working] + [Placeholder])
    END
    END
    Then I got all zero for Q1-Q4 and YearTotal.
    Any of your suggestion is GTEATLY appreciated!!!!!
    Please help!!!!!!!

    Hi, can anyone help? Thanks!!!!!!!!

  • Extract a month from date hierarchy

    I have ssrs report based on cube. I have a date hierarchy where. date hierarchy is Year-Quarter-MonthYear. EG
    2014-Q2-May,2014. as labels display
    Values is like this:[Date].[Year to Month].[Month].&[2002]&[7]. How Can I extract month number like 7 from here so that I can do less than or equal in IIF is ssrs charts.
    I want to compare months with user input month so that I can restrict data in charts. If user select march,2014. I will display data from Jan 2014- Mach 2014 for actual.

    How is the user selecting the month? Is month parameter a free text field? If you're using MDX itself to populate month values then selected month value would be passed in same format itself ie [Date].[Year
    to Month].[Month].&[2002]&[7] etc
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Should I use And or OR in the Where Clause?

    2 Databases have been merged, and in the purge some data was omitted, so I am running clean-up.  Now I need a query to show me if item1 is null, then check olditem1 if both fields are null then ignore the record completely.  But If either field
    has a value I need it returned.  So 1st check item1 if that field is not null, then return the record, if item1 is null, check olditem1 if that field is not null then return the record.  If both fileds are null, ignore the record and let's check
    the next one.
    Sample Data;
    Select
    Test.StaffIDID,
    Test.purchasedfrom,
    Test.date,
    case when Test.item1 is null then Test.olditem1 else null end as [1st Item],
    case when Test.item2 is null then Test.olditem2 else null end as [2nd Item],
    From internetsales Test
    CREATE TABLE Test
    StaffID INT NOT NULL PRIMARY KEY,
    purchasedfrom NVARCHAR(30) NOT NULL,
    date DateTime NOT NULL,
    item1 NVARCHAR(50),
    item2 NVARCHAR(50),
    olditem1 NVARCHAR(50),
    olditem2 NVARCHAR(50)
    INSERT Test VALUES
    (2, 'web1', '2010-01-02', 'stereo', 'NULL', 'NULL', 'NULL'),
    (3, 'web3', '2011-02-15', 'NULL', 'microphone', 'NULL', 'NULL'),
    (4, 'web14', '2014-02-21', 'NULL', 'NULL', 'NULL', 'headset'),
    (5, 'web81', '2015-01-01', 'NULL', 'NULL', 'MP3 Player', 'NULL');
    (6, 'web18', '2011-01-01', 'Dryer', 'NULL', 'MP3 Player', 'NULL');
    (7, 'web8', '2009-01-01', 'NULL', 'NULL', 'Stove', ''NULL);
    (8, 'web828', '2002-01-01', 'NULL', 'NULL', 'NULL', 'USB HUB');
    (9, 'web88', '2007-01-01', 'Refrigerator', 'NULL', 'NULL', 'NULL');
    (10, 'web89', '2009-01-01', 'NULL', 'NULL', 'NULL', 'NULL');
    Desired returned result sets would be StaffIDs: 2,5,6,7,9 -- as they have a value for item1 or olditem1

    Looks like you totally ignored my answer :-(
    well... you have your reason probably...
    You do realize that I gave you the answer from the start?!?
    Hi,
    your sample data do not include any NULL value. Blank string is not NULL.
    Please clarify your question and give us the result that you want to get, according to your sample data.
    * if your data is NULL and not empty string that you can use COALESCE(item1, olditem1,'') in order to get the first value that is not NULL. if both
    NULL then it will return blank string as this is the first value that is not null
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]
    Using nested IIF can be done directly with the
    COALESCE function.
    The execution plan is the same, but the code is much cleaner and easier to write or read.
    There is a reason for this function.
    * In your current needs there are only 2 nested IIF, but you should know about COALESCE function! Once you get more complex situation you will be able to get a solution much faster and probably without any mistake on the first try.
    try to use 5 nested IIF... using COALESCE  this is simple as 2 or 10... all you need is to write all the values and the function will return the first that is not NULL
    Any way, I hope this is useful for people that will come to this thread in future :-)
    -- SOLUTION 1: using nested IIF
    SELECT StaffID, purchasedfrom, date,
    IIF(ITEM1 IS NOT NULL, ITEM1, IIF(OLDITEM1 IS NOT NULL, OLDITEM1,NULL)) AS [1ST ITEM],
    IIF(ITEM2 IS NOT NULL, ITEM2,IIF(OLDITEM2 IS NOT NULL, OLDITEM2,NULL)) AS [2ND ITEM]
    FROM Test
    -- solution 2: using COALESCE
    SELECT
    StaffID, purchasedfrom, date,
    COALESCE(ITEM1, OLDITEM1) AS [1ST ITEM],
    COALESCE(ITEM2, OLDITEM2) AS [2ND ITEM]
    FROM Test
    -- Whish solution look simpler to read, write or use?
    -- The execution plan is the same, but it is always good idea to make sure if you are not sure :-)
    I hope this is useful :-)
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • How to format the Nonemptymember function in an MDX outline formula

    trying to use the NONEMPTYMEMBER function to speed up a complicate nested IIF statement in a ASO cube. Cannot seem to get it to verify.
    I simplified it for testing and still could not get it to verify.
    IIF(NONEMPTYMEMBER([Currency].[USD_Rate],[Product].[No Product]),0,2)
    Thanks
    Tom

    Try defining the NONEMPTYMEMBER Funtion at the beginning of the formula.
    Example:-
    NONEMPTYMEMBER [Product] *(you can specify either a single member or member list or you can use NONEMPTYTUPLE for a cross-dimensional member specification)*
    IIF(([Currency].[USD_Rate],[Product].[No Product]),0,2)
    Regards,
    RSG
    Edited by: RSG on Jun 14, 2011 9:21 PM

  • 1st negative date

    Post Author: mbunschoten
    CA Forum: Formula
    I have a column that holds a running balance by day of materials available. It sometimes happens that this balance goes negative on a certain day. What I want to do is pull only the date when it first went negative and show that date in the material group header.
    I had this working in Report Builder using the PREVIOUS function and some nested IIF's but Crystal wont allowed for a
    formula to refer to itself.
    Any help would be greatly appriciated.
    Thanks,
    Marco

    javaUserMuser wrote:
    How can I express/convert the date (for example) 02(d)-05(m)-1930(y) compared to 01-01-1970
    This is for birthdays for older people for example.
    it is clear that it must be a negative long value but, is there any (standart) programatic means by which I can calculate that?
    Thanks
    DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
    Date grandsonBirthday = formatter.parse("15-05-1970");
    Date grandmaBirthday = formatter.parse("15-05-1920");
    System.out.println(grandmaBirthday.before(grandsonBirthday)); // this prints true%

Maybe you are looking for

  • I rented a movie off itunes and now it won't play, help?!?!

    I tried to play the rented movie when the option box came up saying I could, however the movie had not fully downloaded yet, I assumed it would stream as I watched. However the movie will not play and only shows a blank screen. How can I get it to pl

  • Open hub destination to download the output file into R/3

    Hi Guys,              I have a requirement where i need to down load the data from my BW cube to R/3.For this i am using Open hub destination. While creating the open hub destination we have option called RFC Destination(in that i have selected desti

  • GRN rolls restriction  in MIGO

    hi GRN rolls restriction based on the PO document type , account assignment , please let me know the possibility . Edited by: @SAKHI on Jan 10, 2011 12:33 PM

  • XML SPY - SOAP Envelope

    Hi all, Can any body please suggest me the steps to capture the SOAP envelope using XML SPY? Also while sending a SOAP request through XML Spy to server, i get an empty response. I tried to monitor the packets passing through the network card with th

  • Fox and Geese Question

    Hello, I am creating a fox and geese game using a normal checkerboard. The checkerboard is a .txt file and I am implementing five methods. I am having problems verifying that the geese can move. It is probably a semantics error. I was hoping if someo