Forum Discussion

HarunK's avatar
HarunK
Regular Visitor
3 years ago
Solved

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

 

 

  • 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])) 
    )

2 Replies

  • 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])) 
    )