Forum Discussion

arobinson's avatar
arobinson
Frequent Visitor
6 years ago
Solved

If - Then Statement

I am working on a long IF statement. I am trying to put weights on this statment. When I am running this, it slows the table down to a crawl.    Total % = If (SELECTEDVALUE('Staffing Name Page'[R...
  • Anonymous's avatar
    Anonymous
    6 years ago

     

    Hi arobinson ,

     

    Apart from the suggestions below, you can use this simplified version of DAX code.

     

    Measure =
    VAR _selvalue =
        SELECTEDVALUE ( 'Staffing Name Page'[Region] )
    RETURN
        SWITCH (
            TRUE (),
            _selvalue = "D1"
                || _selvalue = "D2"
                || _selvalue = "D3", ( [Communication Total] * .6 ) + ( [Productivity Total] * .4 ),
            _selvalue = "A1"
                || _selvalue = "A2"
                || _selvalue = "A3", ( [Communication Total] * .8 ) + ( [Productivity Total] * .2 ),
            _selvalue = "DG1", ( [Communication Total] * .6 ) + ( [Productivity Total] * .4 ),
            _selvalue = "DG2", ( [Communication Total] * .7 ) + ( [Productivity Total] * .3 ),
            _selvalue = "DG3"
                || _selvalue = "AH1", ( [Communication Total] * .6 ) + ( [Productivity Total] * .4 ),
            _selvalue = "AH2", ( [Communication Total] * .4 ) + ( [Productivity Total] * .6 ),
            _selvalue = "AH3", ( [Communication Total] * .3 ) + ( [Productivity Total] * .7 )
        )

     

    Regards,

    Harsh Nathani

    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)