Forum Discussion
Multiple column with group by
- 1 year ago
Hi Chetan007 ,
Thank you for reaching out to the Microsoft Fabric Community forum.
Please follow below steps.
1. Created table(Data) with sample data based on your inputs.
2. Created Calculated column (Output) with below DAX code.
Output =VAR CurrentGroup = Data[Group]VAR SubGroup = Data[Sub Group Number]
VAR GroupTable =FILTER(ALL(Data),Data[Group] = CurrentGroup &&Data[Sub Group Number] = SubGroup)
VAR HasWeightGTE30_Y =CALCULATE(COUNTROWS(Data),FILTER(GroupTable,Data[Weight] >= 30 && Data[Flag] = "Y")) > 0
VAR HasOnlyOne_LT30_Y =CALCULATE(COUNTROWS(Data),FILTER(GroupTable,Data[Weight] < 30 && Data[Flag] = "Y")) = 1
VAR AllOthers_GTE30_N =CALCULATE(COUNTROWS(Data),FILTER(GroupTable,Data[Weight] >= 30 && Data[Flag] = "N")) = COUNTROWS(GroupTable) - 1
RETURNIF(HasWeightGTE30_Y,25,IF(HasOnlyOne_LT30_Y && AllOthers_GTE30_N,50,50))3. Dragged all the columns into table visual. please refer output snap and attached PBIX file.If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi Chetan007 ,
Thank you for reaching out to the Microsoft Fabric Community forum.
Please follow below steps.
1. Created table(Data) with sample data based on your inputs.
2. Created Calculated column (Output) with below DAX code.
If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.