Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
arobinson
Frequent Visitor

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'[Region]) = "D1",
(([Communication Total] * .6) + ([Productivity Total] * .4)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "D2",
(([Communication Total] * .6) + ([Productivity Total] * .4)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "D3",
(([Communication Total] * .6) + ([Productivity Total] * .4)) / 1,
If
(SELECTEDVALUE('Staffing Name Page'[Region]) = "DG1",
(([Communication Total] * .6) + ([Productivity Total] * .4)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "DG2",
(([Communication Total] * .7) + ([Productivity Total] * .3)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "DG3",
(([Communication Total] * .6) + ([Productivity Total] * .4)) / 1,
IF
(SELECTEDVALUE('Staffing Name Page'[Region]) = "A1",
(([Communication Total] * .8) + ([Productivity Total] * .2)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "A2",
(([Communication Total] * .8) + ([Productivity Total] * .2)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "A3",
(([Communication Total] * .8) + ([Productivity Total] * .2)) / 1,
If
(SELECTEDVALUE('Staffing Name Page'[Region]) = "AH1",
(([Communication Total] * .6) + ([Productivity Total] * .4)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "AH2",
(([Communication Total] * .4) + ([Productivity Total] * .6)) / 1,
If(SELECTEDVALUE('Staffing Name Page'[Region]) = "AH3",
(([Communication Total] * .3) + ([Productivity Total] * .7)) / 1))))))))))))
1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

 

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)

View solution in original post

3 REPLIES 3
harshnathani
Community Champion
Community Champion

 

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)

lbendlin
Super User
Super User

Create a reference table that holds the [Communication Total] and [Productivity Total] coefficients for each region.

Link that table into your data model and let the data model do all the work.

avatorl
Impactful Individual
Impactful Individual

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.