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.
Good afternoon,
I'm hoping someone can help me fix a measure that is running very poorly because (I believe) of a bi-directional relationship in my model and the nature of the count that is being done.
The model is for healthcare claims data and the agents that sell the policies, just a couple of notes on the data:
This is why there is a bi-directional relationship between vAGENT and vGROUP.
This then flows down to the claims where I am doing the counts and the count changes slightly based on the claim type.
Claim Count =
CALCULATE (
DISTINCTCOUNT ( vCLAIM[Client_Batch_ID] ),
KEEPFILTERS ( vCLAIM[Claim Type] IN { "Life", "Disability" } )
)
+
CALCULATE (
DISTINCTCOUNT ( vCLAIM[Client_Claim_ID] ),
KEEPFILTERS ( vCLAIM[Claim Type] IN { "Dental", "Flex", "Institutional", "Pharmacy", "Professional" } )
)
The problem I am seeing is the way the engine is calculating the measure against the agents, it is generating a scan for almost ever agent in the table (784) and each DISTINCTCOUNT in the measure (2) which is resulting in around 1500 scans.
I have attached a sample model that replicates the problem and I show the server timings from DAX Studio. The first one is a stright sum of paid amount against agent names and runs fine, the second is the claim count against the same list of agents and you can see the multiple scans
I tried creating an agent only table and a bridge table that held the Agent_Group mapping then linking that to vGROUP but the result was the same performance.
Any help would be greatly appreciated.
Solved! Go to Solution.
Using information from this article https://www.sqlbi.com/articles/analyzing-distinctcount-performance-in-dax/
I was able to modify the measures and increase the speed of the visual by 225 X.
Old Count = DISTINCTCOUNT ( vCLAIM[Client_Claim_Type_ID] )
New Count = SUMX ( DISTINCT ( vCLAIM[Client_Claim_Type_ID] ), 1 )
Small suggestions:
Why not combine all dimensions ( vClient, vGroup, vGroupDivision and vGroupDivision ...) it into one dimension ( vGroupDivision ) this would simplify the model and improve the performance and create a proper start schema.
Next, you can join vAgent M*M with vCLAIMS but not bidi anymore, vAgent propagating claims. as below
btw, nice to see you back John!
Thank you @Mariusz for the reply.
I should have mentioned that the real model is running on an SSAS back end which does not support the many to many *:* relationships. I didn't see a version of SSAS that does support *:*, do you know of one?
I also need vAGENT to filter three lower level tables (claims, invoices, enrollment) all of which link up to the GroupDivisionPlan so that is why I am coming in from that level.
If I make it a true star schema by denormalizing vCLIENT, vGROUP, vGROUPDIVISION and vGROUPDIVISIONPLAN I would not be able to hook agents in, again because of the many to many not being supported although I could do that with a bridge table.
One thing I am going to try is adding a claim_count_ID to the vCLAIM that uses the correct field (claim_ID or batch_ID) depending on the claim type. That should cut the calls to the storage engine in half.
Using information from this article https://www.sqlbi.com/articles/analyzing-distinctcount-performance-in-dax/
I was able to modify the measures and increase the speed of the visual by 225 X.
Old Count = DISTINCTCOUNT ( vCLAIM[Client_Claim_Type_ID] )
New Count = SUMX ( DISTINCT ( vCLAIM[Client_Claim_Type_ID] ), 1 )
HI @jdbuchanan71,
I think this should more relate to your data model relationship and KEEPFITLERS, probably you can take a look at following documents about AS tabular relationship and KEEPFITLERS function:
Relationships in analysis services tabular models
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |