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
Ffitzpatrick47
Helper II
Helper II

dax to join a table to an aggregate table

This is for excel 2016, not really power bi, but let's face it.  Mrexcel is a ghost town for power pivot

 

anyway I have a table a

Table aTable a

 

And a table that I need to aggregate table b

image.png

 

That I need to aggregate grouped on d2 (Table b aggregate):

image.png

 

Then I want to join table b aggregate with table 1 so I can get this pivottable

image.png

 

I bet there's a super complex nested groupby dax formula to do this, but I can't figure it out.  How would you even step your way to the full formula by testing each nest unless you use dax studio? 

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Ffitzpatrick47,

 

I'm not sure how to achieve these with dax excel version, but these operation is possible to achieve in power bi.

 

Sample table formula:

b aggregate = 
SUMMARIZE (
    FILTER ( b, [d4] IN VALUES ( a[d3] ) ),
    [d2],
    [d4],
    "Percent", DIVIDE (
        CALCULATE ( SUM ( b[value] ), ALL ( b ), VALUES ( b[d2] ), VALUES ( b[d4] ) ),
        CALCULATE ( SUM ( b[value] ), ALL ( b ), VALUES ( b[d2] ) ),
        -1
    )
)

join Table = ADDCOLUMNS(a,"Percent",[measure]*LOOKUPVALUE('b aggregate'[Percent],'b aggregate'[d2],a[d2],'b aggregate'[d4],a[d3]))

6.PNG7.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

There's a myth that excel 2016 handles variables, but I don't even have the simplest code to test it.  I can break up one of my successful calculate equations like

 

var f = filter(all(x[a],[a]=1)

calculate(sum(x[b]),f) but I don't see it working.  It just seems too good to be true

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.

Top Solution Authors