Forum Discussion
akhilduvvuru
3 years agoHelper IV
Add custom Total row
Hi, I have a requirement to add custom total row in Power BI table visual Source Data: DIM_TABLE ID Category 1 Apple 2 Orange 3 Fruits Total 4 Pen 5 Scale 6 Ink Po...
- 3 years ago
We have to break the link when calculating the total which we can do using REMOVEFILTER like this.
Sales with total = VAR _Category = SELECTEDVALUE ( DIM_TABLE[Category] ) RETURN SWITCH ( TRUE (), _Category = "Fruits Total", CALCULATE ( SUM ( FACT_TABLE[SalesAmount] ), REMOVEFILTERS ( DIM_TABLE ), DIM_TABLE[Category] IN { "Apple", "Orange" } ), _Category = "Stationary Total", CALCULATE ( SUM ( FACT_TABLE[SalesAmount] ), REMOVEFILTERS ( DIM_TABLE ), DIM_TABLE[Category] IN { "Pen", "Scale", "Ink Pot" } ), _Category = "Clothing Total", CALCULATE ( SUM ( FACT_TABLE[SalesAmount] ), REMOVEFILTERS ( DIM_TABLE ), DIM_TABLE[Category] IN { "Shirt", "Pant" } ), SUM ( FACT_TABLE[SalesAmount] ) )
jdbuchanan71
3 years agoSuper User
We have to break the link when calculating the total which we can do using REMOVEFILTER like this.
Sales with total =
VAR _Category = SELECTEDVALUE ( DIM_TABLE[Category] )
RETURN
SWITCH (
TRUE (),
_Category = "Fruits Total", CALCULATE (
SUM ( FACT_TABLE[SalesAmount] ),
REMOVEFILTERS ( DIM_TABLE ),
DIM_TABLE[Category] IN { "Apple", "Orange" } ),
_Category = "Stationary Total", CALCULATE (
SUM ( FACT_TABLE[SalesAmount] ),
REMOVEFILTERS ( DIM_TABLE ),
DIM_TABLE[Category] IN { "Pen", "Scale", "Ink Pot" } ),
_Category = "Clothing Total", CALCULATE (
SUM ( FACT_TABLE[SalesAmount] ),
REMOVEFILTERS ( DIM_TABLE ),
DIM_TABLE[Category] IN { "Shirt", "Pant" } ),
SUM ( FACT_TABLE[SalesAmount] )
)
akhilduvvuru
3 years agoHelper IV
Thanks jdbuchanan71 !