Forum Discussion
Grouping of columns to Create new Column
Hi Sandhya877 ,
I created a sample pbix file(see the attachement), please check if that is what you want.
1. Create a dimension table as below
2. Create a measure as below
Measure =
VAR _category =
SELECTEDVALUE ( 'Category'[Category] )
RETURN
SWITCH (
_category,
"Bike Accessories",
CALCULATE (
SUM ( 'Table'[quantity] ),
FILTER (
'Table',
'Table'[SubCategory1] = "Accessories"
&& 'Table'[Subcategory2] IN { "Bike Racks", "Bike Stands" }
)
),
"All Accessories",
CALCULATE (
SUM ( 'Table'[quantity] ),
FILTER (
'Table',
'Table'[SubCategory1] = "Accessories"
&& 'Table'[Subcategory2]
IN {
"Bike Racks",
"Bike Stands",
"Bottels",
"Cleanign Supplies",
"Hydration Packs",
"Tires"
}
)
)
)
Best Regards
Thank you. this is helpful, What if the subcategory2 is another related table ?
- Anonymous2 years agoNot applicable
Hi Sandhya877 ,
Thanks for your feedback. Since the subcategory2 is another related table, could you please provide some raw data in these tables (exclude sensitive data) with Text format and the relation info(cardinality, based field etc) if it created any relationship with the other table. It would be helpful to find out the solution. You can refer the following link to share the required info:
How to provide sample data in the Power BI Forum
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
- Sandhya8772 years agoFrequent Visitor
I am not a super user to upload the pbix file.
- Anonymous2 years agoNot applicable
Hi Sandhya877 ,
It's OK. You can refer the following link to paste the sample data with Text format in your reply directly. And please share the relation info(cardinality, based field etc) if table which the field [subcategory2] exist in created any relationship with the other table. Thank you.
How to provide sample data in the Power BI Forum
Best Regards