Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
HarunK
Regular Visitor

DAX error

Hi, I would like to get help with the following DAX:

 

I try to group number of customers by their deposit balance:

 

Customer groups = SUMMARIZE ( GROUPBY ( MonthsTrend, MonthsTrend[CUST.NO], "Total Balance", SUM (MonthsTrend[ LOC.BAL. ]) ), "Balance Group", SWITCH ( TRUE (), SUM (MonthsTrend[ LOC.BAL. ]) <= 1000, "0-1000", SUM (MonthsTrend[ LOC.BAL. ]) <= 10000, "1000-10000", "Over 10000" ), "Total Customers", COUNTROWS (VALUES (MonthsTrend[CUST.NO])) )

 

However, I receive the following error:

 

Function "Groupby" scalar expressions have to be aggregation functions over CurrentGroup()

 

What am I doing wrong?

 

Thanks in advance

 

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @HarunK 

try like:

Customer groups = 
SUMMARIZE ( 
     GROUPBY ( 
         MonthsTrend, 
         MonthsTrend[CUST.NO], 
         "Total Balance", 
          SUMX(CURRENTGROUP(), MonthsTrend[ LOC.BAL. ]) 
       ),          
      "Balance Group", 
       CALCULATE(SWITCH ( 
            TRUE (), 
            SUM (MonthsTrend[ LOC.BAL. ]) <= 1000,             "0-1000", 
            SUM(MonthsTrend[LOC.BAL.]) <= 10000
            "1000-10000", 
            "Over 10000" 
        )), 
        "Total Customers", 
         COUNTROWS(VALUES (MonthsTrend[CUST.NO])) 
)

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @HarunK 

try like:

Customer groups = 
SUMMARIZE ( 
     GROUPBY ( 
         MonthsTrend, 
         MonthsTrend[CUST.NO], 
         "Total Balance", 
          SUMX(CURRENTGROUP(), MonthsTrend[ LOC.BAL. ]) 
       ),          
      "Balance Group", 
       CALCULATE(SWITCH ( 
            TRUE (), 
            SUM (MonthsTrend[ LOC.BAL. ]) <= 1000,             "0-1000", 
            SUM(MonthsTrend[LOC.BAL.]) <= 10000
            "1000-10000", 
            "Over 10000" 
        )), 
        "Total Customers", 
         COUNTROWS(VALUES (MonthsTrend[CUST.NO])) 
)

Thank you very much FreemanZ!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.