Welcome, Guest
Username Password: Remember me
Please ask here your questions related to DAX and PowerPivot for Excel or PowerPivot for SharePoint. To post your question or reply you need to login first!
  • Page:
  • 1

TOPIC: Calculated measure help

Calculated measure help 1 year, 8 months ago #88

  • LoganIsDax
I'm having trouble figuring out this DAX stuff. I know there's a simple answer here but I can't figure it out...

[K1Code] table
K1Code-----AllocCode
ORDINC-----WBC
LTCGL-------CGL
INTINC-------WBC

[AMOUNT] table
EntityID-----K1Code-----Amount
B-LIQ-------ORDINC-----9500
B-LIQ-------LTCGL-------25900
B-LIQ-------INTINC-------3400

[RATIOS] table
EntityID-----PtrID-----AllocCode-----AllocPct
B-LIQ--------ABC------WBC-----------56%
B-LIQ--------XYZ-------WBC-----------23%
B-LIQ--------GUY------WBC-----------21%
B-LIQ--------ABC------CGL------------75%
B-LIQ--------XYZ-------CGL------------10%
B-LIQ--------GUY------CGL------------15%


What I'm trying to do is create a Pivot table with PtrID on the Rows Label, K1Code on the Columns label, and the Values be an expression multiplying the PtrID's AllocPct and the K1Code Amount based on the AllocCode assigned to each. So for example, the value where Row PtrID = ABC and Column K1Code = LTCGL should be 19425.

Can anyone help me come up with a calculated measure to do this? I keep running into context errors.

Thanks!

Re: Calculated measure help 1 year, 8 months ago #89

  • Vidas
  • OFFLINE
  • Moderator
  • Posts: 65
  • Karma: 3
Logan could you please clarify relationships between tables? It is clear that Amounts is related to K1Code on K1Code. Is table Ratios related to Amount table just on EntityID?
Please click on the "Thank you" button for replies that are helpful!

Re: Calculated measure help 1 year, 8 months ago #90

  • LoganIsDax
There's no relationship between RATIOS and AMOUNT tables.

The only relationship is AMOUNT[K1Code]-->K1CODE[K1Code] as you have pointed out.

Also there is a Calculated Column [AllocCode] in AMOUNT that is =RELATED(K1CODE[AllocCode]).

Does that help?

Re:Calculated measure help 1 year, 8 months ago #93

  • Vidas
  • OFFLINE
  • Moderator
  • Posts: 65
  • Karma: 3
Hi Logan,

Very interesting problem you have here, as you don't have relationships between tables.

Lets first create measure AvgAllocPct in the Amounts table with following DAX formula:

=Average(Ratios[AllocPct])


I need this calculated measure to deal with cases when more than one row with AllocPct could be returned.

Now lets create our calculated measure with following DAX formula:

=CALCULATE(SUMX(Amount, Amount[Amount] * Amount[AvgAllocPct](FILTER(Ratios, Ratios[AllocCode] = Amount[AllocCode]))))

Could you please try this and see if that works for you? Please let me know - I would be very interested to hear if that works as you expected.

Regards,

Vidas Matelis
Please click on the "Thank you" button for replies that are helpful!
  • Page:
  • 1
Moderators: Vidas, dgosbell
Time to create page: 2.16 seconds
 

Varigence Vivid