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
vickyprudhvi
Helper IV
Helper IV

Measure in SSAS 2012

question.jpg

Hi Guys,

Sorry for posting this hear . I am not sure where to post this question.

Following is a sencario, I need to calculate average medical paymet for each primary body part. But I am not able to create correct measure using dax. Kindly help me out

2 ACCEPTED SOLUTIONS
austinsense
Impactful Individual
Impactful Individual

This is a classic many to many problem (M2M). Your problem is that the relationships only flow from the one side to the many side of the tables. With emoticons ...

 

Dim Body Part >> Body Part Fact Smiley Happy

Body Part Fact >> Dim Claim Smiley Sad

Dim Claim >> Derivation Fact Table Smiley Happy

 

You can handle this in Power BI or SSAS 2016 with bi-directional filters(which is much much easier!) - in earlier versions of SSAS you need to take this approach.  It's actually a very simple solution ...

 

Medical Amt = CALCULATE( SUM( Derivation Fact Table[Medical Amt]), Body Part Fact)

Count Claims = CALCULATE( COUNTROWS( Derivative Fact Table), Body Part Fact)

Average Payment = DIVIDE( [Medical Amt], [Count Claims])


 

I may not have your metrics exactly right but this should get you started - the solution is to include the table in the middle of the M2M relationship as an argument in a calculate function.

 

Kudos to you for including a data model diagram.

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

View solution in original post

@vickyprudhvi hey great question - (looking at your diagram) you need the relationship in your report to flow from the right to the left.  If you have a need for the relationship to flow in this direction ...

 

Derivation Fact Table >> Dim Claim

 

Then you'll need to include that fact table as a third argument in your calculate function.  I don't see a need for you to do that.  Just give the DAX a try and see if the results are good.

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

View solution in original post

3 REPLIES 3
austinsense
Impactful Individual
Impactful Individual

This is a classic many to many problem (M2M). Your problem is that the relationships only flow from the one side to the many side of the tables. With emoticons ...

 

Dim Body Part >> Body Part Fact Smiley Happy

Body Part Fact >> Dim Claim Smiley Sad

Dim Claim >> Derivation Fact Table Smiley Happy

 

You can handle this in Power BI or SSAS 2016 with bi-directional filters(which is much much easier!) - in earlier versions of SSAS you need to take this approach.  It's actually a very simple solution ...

 

Medical Amt = CALCULATE( SUM( Derivation Fact Table[Medical Amt]), Body Part Fact)

Count Claims = CALCULATE( COUNTROWS( Derivative Fact Table), Body Part Fact)

Average Payment = DIVIDE( [Medical Amt], [Count Claims])


 

I may not have your metrics exactly right but this should get you started - the solution is to include the table in the middle of the M2M relationship as an argument in a calculate function.

 

Kudos to you for including a data model diagram.

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

@austinsense - thank you for ur reply. I still have a doubt. u said we need to include middle table of M2M but there are 2 tables  Claim and Body part fact. then why are you including only bodypart fact table.

@vickyprudhvi hey great question - (looking at your diagram) you need the relationship in your report to flow from the right to the left.  If you have a need for the relationship to flow in this direction ...

 

Derivation Fact Table >> Dim Claim

 

Then you'll need to include that fact table as a third argument in your calculate function.  I don't see a need for you to do that.  Just give the DAX a try and see if the results are good.

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

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.