Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
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.
Solved! Go to Solution.
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)
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)
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.
1) learn how to use variables
https://docs.microsoft.com/en-us/power-bi/guidance/dax-variables
https://www.youtube.com/watch?v=9SV2VnYbgg4
2) do not use multiple nested IF, use SWITCH
https://docs.microsoft.com/en-us/dax/switch-function-dax
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 8 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 23 | |
| 14 | |
| 10 | |
| 6 | |
| 5 |