The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I am trying to fix a DAX-calculation were I basically want to take No of Emails + No of Calls + No of Chats / No of Orders
However there are some filters on each metrics that need to be accounted for. For Emails and Calls I want to exclude rows with:
Wrap Up Group = "BO Action" AND "BO Support"
and
Workgroup = *GDPR* (if there is a value with GDPR in it, it should be excluded)
For Chats we want to calculate on different metrics depending what Agent Type it is. If it's Agent Type = "Live Agent" then it should calculate No of Chats Answered LA, if it's Agent Type = "VA Agent" then it should calculate No of Chats Answered VA.
Else No of Chats Answered
Here is a calculation I created trying to fix this accordingly:
Out of cursiousity, is there any best practice here for this specifically case? For instance the Chat part? Because I have a lot of cases with these kind of calculations and would love to have some tips or suggestions about BP.
BR Fredrik
@Anonymous
First of all, if you want fast DAX, you cannot use SEARCH. Easy as that. Instead, you should use Power Query to massage your data in such a way that looking for GDPR becomes a simple filter on a column.
Second, you should never filter a table if you can filter a column. This is the golden rule of DAX programming. Probably the most important in order to have fast and correct formulas. Instead, you should use the column(s) and KEEPFILTERS.
Also, nested IF's are better written with SWITCH. Doing something like this on a text field
MAX(dim_agenttype[Agent Type]) = "Live Agent",
is brittle (sometimes it's OK if you know for sure there's gonna be only one value in the current context) and should most likely be replaced by SELECTEDVALUE.
This is what I can tell about this code at first sight... Can't, obviously, comment on the performance.
Thanks for response!
Sometimes in the data I get the value "Infinite" so it is obviously not working as planned...
About your conclusions:
Sorry if this code is looking crazy, I am basically a QLIK developer that are currently trying to learn best practices for PBI atm. It is hard in terms of logic to go from on language to another, they are very different in many regards.
BR Fredrik
There would be too much to expand upon. Grab a good book on DAX and study. THe best by far is "The Definitive Guide to DAX" by Alberto Ferrari and Marco Russo.
About your conclusions:
Great, I'll buy that book!
Can you give an example if I need a flag to filter Source = Genesys as an example. Should I then create a DAX formula for this?
BR Fredrik
@Anonymous
Please learn to use Power Query. It can do anything that you could imagine with your data. Most things just by clicking a button. There are millions of vids on YT about Power Query...
Unfortunately this does not help me at all short term.
I need more specific help rather then "learn Power Query".
User | Count |
---|---|
27 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
7 | |
6 |