Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Show target reduction

Hey BI Community,   Not sure what term(s) to search for to see if someone has already accomplished what I'm looking to do so if there is a potential solution that someone already knows of and can p...
  • Anonymous's avatar
    Anonymous
    3 years ago

    rsbin ,

    Thank you so much for getting me pointed in the right direction, I wouldn't have been able to accomplish this task without your support.

    I apologize it took me a little longer than anticipated but I have finally been able to put together something that accomplishes what I was trying to do:


    To get this to calculate the reduction properly I had to use the following:

    zTestProjectedReduction = 
    VAR minDate = CALCULATE(MIN('table'[weekEndingExpire]),ALLSELECTED('table'[weekEndingExpire]))
    VAR maxDate = MAX('table'[weekEndingExpire])
    VAR noWeeks = DATEDIFF(minDate, maxDate, WEEK) + 1
    VAR noEmps = SELECTEDVALUE('table2'[Value])
    VAR compTar = SELECTEDVALUE('table3'[Value])
    
    Return
    CALCULATE(
        [zProjectedExpTotSum] - ((noEmps * compTar) * noWeeks),
        'table'[weekEndingExpire] <=maxDate
    )

    The difference between my first attempt and the second is I had to "calculate" the minDate because the previous declaration for that variable:

    VAR minDate = MIN('table'[weekEndingExpire])

    would basically default the value to 1 for every week and not take into consideration previous weeks in the date range.

     

    I also ended up created two new tables ("table2" & "table3") that essentially allow the user of the report to select the number of employees and a completion target.  This in turn allows the projection the the bar graph to update dynamically based on the user selection.