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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arobinson
Frequent Visitor

DAX Performance Slowness

Hey all, 

 

Working through a few different querries on a single table visual. This is preventing slowness in the table. Please provide suggestions on how to make the following a little faster. 

 

Total % =
VAR _selvalue =
SELECTEDVALUE ( 'Credentialing Name Sheet'[Territory Type])
RETURN
SWITCH (
TRUE (),
_selvalue = "D1"
|| _selvalue = "D2"
|| _selvalue = "D3", ( [Communication Total] * .4 ) + ( [Productivity Total] * .6 ),
_selvalue = "DG1", ( [Communication Total] * .4 ) + ( [Productivity Total] * .6 ),
_selvalue = "DG2", ( [Communication Total] * .7 ) + ( [Productivity Total] * .3 ),
_selvalue = "DG3", ( [Communication Total] * .95 ) + ( [Productivity Total] * .05 ),
_selvalue = "A1" ,[Productivity Total] ,
_selvalue = "A2" , [Productivity Total] ,
_selvalue = "A3", ( [Communication Total] * .05) + ( [Productivity Total] * .95 ),
_selvalue = "O1", [Communication Total],
_selvalue = "O2", ( [Communication Total] * .4 ) + ( [Productivity Total] * .6),
_selvalue = "O3", [Productivity Total] ,
_selvalue = "NR1", ( [Communication Total] * .4 ) + ( [Productivity Total] * .6))
 
 
AND 
 
 
Communication Total =
IFERROR(VAR _selvalue =
SELECTEDVALUE ( 'Credentialing Name Sheet'[Territory Type] )
RETURN
SWITCH (
TRUE (),
_selvalue = "D1"
|| _selvalue = "D2"
|| _selvalue = "D3", ( 'Range Goals'[Developed Call % to Goal] + 'Range Goals'[Call Quality % to Goal] ) / 2,
_selvalue = "DG1"
|| _selvalue = "DG2"
|| _selvalue = "DG3", ( 'Range Goals'[Developing Calls % to Goal] + 'Range Goals'[Call Quality % to Goal] ) / 2,
_selvalue = "A1", ( 'Range Goals'[Admin Call % to Goal] ),
_selvalue = "O1", ( 'Range Goals'[Other Call % to Goal] + 'Range Goals'[Call Quality % to Goal] ) / 2,
_selvalue = "O3", ( 'Range Goals'[Other Call % to Goal] )),Blank()
)
 
2 ACCEPTED SOLUTIONS
AlB
Super User
Super User

Hi @arobinson 

Total % =
VAR _selvalue =
    SELECTEDVALUE ( 'Credentialing Name Sheet'[Territory Type] )
VAR productivityTotal_ = [Productivity Total]
VAR communicationTotal_ = [Communication Total]
RETURN
    SWITCH (
        TRUE (),
        _selvalue = "D1"
            || _selvalue = "D2"
            || _selvalue = "D3",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 ),
        _selvalue = "DG1",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 ),
        _selvalue = "DG2",
             ( communicationTotal_ * .7 ) + ( productivityTotal_ * .3 ),
        _selvalue = "DG3",
             ( communicationTotal_ * .95 ) + ( productivityTotal_ * .05 ),
        _selvalue = "A1", productivityTotal_,
        _selvalue = "A2", productivityTotal_,
        _selvalue = "A3",
             ( communicationTotal_ * .05 ) + ( productivityTotal_ * .95 ),
        _selvalue = "O1", communicationTotal_,
        _selvalue = "O2",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 ),
        _selvalue = "O3", productivityTotal_,
        _selvalue = "NR1",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 )
    )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

AlB
Super User
Super User

@arobinson 

Note you are invoking the measures many times. By using variables you can have the measures executed just once. You haven't posted the code for [Productivity Total]. Perhaps that can be optimized as well. I don't see much room for performance improvement in [Communication Total], given its simplicity.  You can though use IN as a way to make the code more legible and more convenient to create. For instance:

_selvalue  IN {"D1", "D2", "D3"}

is equivalent to

_selvalue = "D1"
|| _selvalue = "D2"
|| _selvalue = "D3"

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

@arobinson 

Note you are invoking the measures many times. By using variables you can have the measures executed just once. You haven't posted the code for [Productivity Total]. Perhaps that can be optimized as well. I don't see much room for performance improvement in [Communication Total], given its simplicity.  You can though use IN as a way to make the code more legible and more convenient to create. For instance:

_selvalue  IN {"D1", "D2", "D3"}

is equivalent to

_selvalue = "D1"
|| _selvalue = "D2"
|| _selvalue = "D3"

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

AlB
Super User
Super User

Hi @arobinson 

Total % =
VAR _selvalue =
    SELECTEDVALUE ( 'Credentialing Name Sheet'[Territory Type] )
VAR productivityTotal_ = [Productivity Total]
VAR communicationTotal_ = [Communication Total]
RETURN
    SWITCH (
        TRUE (),
        _selvalue = "D1"
            || _selvalue = "D2"
            || _selvalue = "D3",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 ),
        _selvalue = "DG1",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 ),
        _selvalue = "DG2",
             ( communicationTotal_ * .7 ) + ( productivityTotal_ * .3 ),
        _selvalue = "DG3",
             ( communicationTotal_ * .95 ) + ( productivityTotal_ * .05 ),
        _selvalue = "A1", productivityTotal_,
        _selvalue = "A2", productivityTotal_,
        _selvalue = "A3",
             ( communicationTotal_ * .05 ) + ( productivityTotal_ * .95 ),
        _selvalue = "O1", communicationTotal_,
        _selvalue = "O2",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 ),
        _selvalue = "O3", productivityTotal_,
        _selvalue = "NR1",
             ( communicationTotal_ * .4 ) + ( productivityTotal_ * .6 )
    )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors