Forum Discussion
DAX HELP Multi Sumx alternative?
- 9 years ago
Anonymous
Thanks for that :)
You will have to change the measure if there are multiple fact tables involved.
I have two ideas:
- Use SUMX with SUMMARIZECOLUMNS. SUMMARIZECOLUMNS doesn't require you to specify the table to be summarized, and if you add a column with an expression, it will automatically remove rows where the expression is blank.
(Side note: SUMMARIZECOLUMNS didn't previously work within a filter context, but now it appears to work. Interesting article here)PnL SUMMARIZECOLUMNS = SUMX ( SUMMARIZECOLUMNS ( 'CALENDAR'[DATE], HE[HE], CTRL[CTRL], DataClass[ZONE], "ExpressionToSum", ( [INCS MWH] + [DECS MWH (neg)] ) * [DART Spread] + [DEV Cost INCS] + [DEV Cost DECS] ), [ExpressionToSum] ) - Use the SUMMARIZE method with multiple fact tables by SUMMARIZE-ing each table and take the union.
PnL SUMMARIZE Union = VAR BIDS_Summarized = SUMMARIZE ( BIDS, 'CALENDAR'[DATE], HE[HE], CTRL[CTRL], DataClass[ZONE] ) VAR LMP_Summarized = SUMMARIZE ( LMP, 'CALENDAR'[DATE], HE[HE], CTRL[CTRL], DataClass[ZONE] ) VAR DEV_Summarized = SUMMARIZE ( LMP, 'CALENDAR'[DATE], HE[HE], CTRL[CTRL], DataClass[ZONE] ) VAR Union_Summarized = DISTINCT ( UNION ( BIDS_Summarized, LMP_Summarized, DEV_Summarized ) ) RETURN SUMX ( Union_Summarized, ( [INCS MWH] + [DECS MWH (neg)] ) * [DART Spread] + [DEV Cost INCS] + [DEV Cost DECS] )
I think the SUMMARIZECOLUMNS version should perform best, but would be interested in how actual performance turns out.
Cheers,
Owen :)
- Use SUMX with SUMMARIZECOLUMNS. SUMMARIZECOLUMNS doesn't require you to specify the table to be summarized, and if you add a column with an expression, it will automatically remove rows where the expression is blank.
Thanks Anonymous and Anonymous for the responses. The best I can answer is this was the first pattern I used that acheieved the results I was expecting (again- mainly having to do with the whole being the sum of its parts i.e. sumx). Regualr SUM wasnt getting it done.
Another wrinkle is that I originally came up with this pattern almost two years ago in excel power pivot. At the time BI and Excel features were more aligned. I don't think that's making a difference in my case though.
The spirit behind my post was to see if anyone glancing at my "quad" sumx would recogise the pattern and say---"oh...i see what he's trying to do...but he should use "_ _ _ _ _ _" expression instead."
Also, here's an old post that originally helped me come up with my quad sumx formula- Anonymous looks like the multi-sumx was your idea to begin with! LOL. I'm just realizing it now...check it out...too funny.
Thnx to anyone willing to help :robothappy:
Okay, THAT is hilarious :)
"What dumb ass had you write quad-nested sumx?"
"Uh... you did".
:)