Forum Discussion

ToddChitt's avatar
ToddChitt
Super User
9 years ago
Solved

BUG: What If parameter not working

I started testing the What If parameter. It doesn't work. I created a simple table of two columns (Year and Value) with three rows. (See screen shot.) I added a What If Parameter and an appropriate s...
  • OwenAuger's avatar
    9 years ago

    Hi ToddChitt

     

    What If Parameters are practically only usable within measures, not calculated columns. 

     

    Calculated columns are computed at data refresh, in an empty (i.e. unfiltered) filter context (but within the row context of the table).

     

    For this reason, the expression [Adding Value] within a calculated column will not respond to any filters in the report, and will be evaluated in an empty filter context. This means it takes the default value specified when the parameter was created - it looks like this is 10 in your case.

     

     

    To get the result you were looking for, you could instead define a measure, using SUMX to iterate over the rows of 'Table1':

     

    Measure producing desired result =
    SUMX (
        'Table1',
        'Table1'[Value] + [Adding Value]
    )

    Regards,

    Owen

  • ToddChitt's avatar
    ToddChitt
    9 years ago

    OwenAuger: Thanks, it did the trick.

     

    In reality, I was looking to also NOT add in the Parameter's value if it was the current year, but that was easy enough to add in. My final measure for the sample dataset is this:

     

    Measure producing desired result =
    SUMX (
        'Table1',
        'Table1'[Value] + IF('Table1'[Year] <> YEAR(TODAY()), [Adding Value],0)
    )

     

    Many Thanks!