Forum Discussion
SummarizeColumns with Multiple Filters
- 9 years ago
You can do something like this:
Table = CALCULATETABLE ( SUMMARIZECOLUMNS ( 'Product'[Emonth], 'Product'[Bills], 'Product' ), 'Product'[Emonth] = "May", 'Product'[Bills] = "Groceries" )I added 'Product' as a filter argument to SUMMARIZECOLUMNS, then wrapped in CALCULATETABLE containing the column filters.
(Since the table is calculated in an unfiltered context, I turned your FILTER functions into single column filters.)
Does this give the intended result?
Cheers,
Owen
Hmm wat happens when you put in the Type column, Does it still show the breakdown?
| Bills | Emonth | TYPE | Costs |
| Groceries | May | A | 300 |
| Groceries | May | B | 100 |
This will work below if you only want values for the Groceries
Table = CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
'Product',
'Product'[Emonth],
'Product'[Bills],
'Product'[Type]
),
"Costs", CALCULATE(SUM('Product'[Costs] ),'Product'[Bills] = "Groceries")
)//,
//'Product'[Emonth] = "May"
// 'Product'[Bills] = "Groceries"
)Or this if you want the other Bills data also.
Table = CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
'Product',
'Product'[Emonth],
'Product'[Bills],
'Product'[Type]
),
"Costs", CALCULATE(SUM('Product'[Costs] ),'Product'[Bills] = "Groceries" || 'Product'[Bills] = "Other")
)//,
//'Product'[Emonth] = "May"
// 'Product'[Bills] = "Groceries"
)- GilbertQ9 years agoSuper User
Hi there
In order to get it working the way that you want, you do not want to place the filter on your calculation. But you rather want to place the filter on your Table you are creating.
The code below will get you the data for just the Months of May and June
Table = CALCULATETABLE ( ADDCOLUMNS ( SUMMARIZE ( 'Product', 'Product'[Emonth], 'Product'[Bills], 'Product'[Type] ), "Costs", CALCULATE(SUM('Product'[Costs] )) ), 'Product'[Emonth] = "May" || 'Product'[Emonth] = "June" ) - spoony9 years agoHelper I
Thanks GilbertQ
Its almost working, i try to use it on the month and its not showing the correct totals for each type or Bills though:
Table = CALCULATETABLE ( ADDCOLUMNS ( SUMMARIZE ( 'Product', 'Product'[Emonth], 'Product'[Bills], 'Product'[Type] ), "Costs", CALCULATE(SUM('Product'[Costs] ),'Product'[Emonth] = "May" || 'Product'[Emonth] = "June") ) , 'Product'[Emonth] = "May" || 'Product'[Emonth] = "June" ) - spoony9 years agoHelper I
Ah everything is working now, Thanks heaps!!
Now i can justify my $20/hr job !!
- GilbertQ9 years agoSuper User
Glad to be of assistance... Kudos!