I tried using group by DAX function in PowerBI as Measure, New Column, New Table but I get an error in validating the function,
New Table = GROUPBY(
'tab1',
'tab1'[color],
"Group By color",
sum('tab1'[count_lables])
)
Error : Function 'GROUPBY' scalar expressions have to be Aggregation functions over CurrentGroup(). The expression of each Aggregation has to be either a constant or directly reference the columns in CurrentGroup().
GROUPBY is a type of query which is also used in Power BI. There is an editor in Power BI, known as the “Query Editor” window, which has various queries for accessing data. Such a query is GROUPBY which is used to group rows based on a given value.
Use an aggregate function to group by one or more columns Select Group by on the Home tab. Select the Advanced option, so you can select multiple columns to group by. Select the Country column. Select Add grouping.
Grouping tables in Power BI is a powerful modeling technique that allows you to select from overlapping groups either in a slicer or across a matrix. Useful for scenarios where say, you have several ad campaigns going on and an individual product can be a part or more than one campaign.
The error says you need to use an aggregation function over a group, you are using SUM
function which doesn't sum values over any group. In your case you need to use SUMX
aggregation function with CURRENTGROUP()
option. The CURRENTGROUP
determines the groups that must be added based on the current row.
Try using the below expression instead.
New Table = GROUPBY (
tab1,
tab1[color],
"Group by color", SUMX ( CURRENTGROUP (), tab1[count lables] )
)
Let me know if this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With