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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rjiang
Helper I
Helper I

SUMX SUMMARIZE not working as intended

I am trying to get a matrix to display the results of this measure. Essentially, I want it to flag a user with a 1 if the clicks in the last 3 months are greater than or equal to 3 and flag with a 0 otherwise. However, the measure shown below is not evaulating as intended.

 

 

Active =


VAR Active =
SUMX(
SUMMARIZE('Usage Data','Usage Data'[gstClientID]),
IF([Clicks Last 3 Months]>=3,1,0)
)

RETURN IF(ISBLANK(ACTIVE),0,ACTIVE)
 
 
Here is the measure (working as expected) used in [Active]
 
Clicks Last 3 Months =

VAR Clicks_Last_3 =
CALCULATE(
SUMX(VALUES('Usage Data'[gstClientID]),[Clicks]),
DATESINPERIOD('Date Lookup'[Date],
DATE(
YEAR(MAX('Date Lookup'[Date])),
MONTH(MAX('Date Lookup'[Date])),1)-1,
-3,
MONTH
)
)

RETURN IF(ISBLANK(Clicks_Last_3),0,Clicks_Last_3)

//Calculates clicks in the last 3 months (does not include current month)
20 REPLIES 20
rjiang
Helper I
Helper I

I've uploaded the sample data here:

 

https://drive.google.com/file/d/1S5mw2j6yK11k18JuUA0tnWVGqniNGYCm/view?usp=sharing

 

I am expecting 2022-03 in the Active tab to evaluate to a total of 15,825

tamerj1
Super User
Super User

Hi @rjiang 

You can try

VAR Active =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( 'Usage Data', 'Usage Data'[gstClientID] ),
        "@ClicksLast3Month", [Clicks Last 3 Months]
    ),
    IF ( [@ClicksLast3Month] >= 3, 1, 0 )
)

 

Thanks. The output has changed slightly, but I'm still significantly off from what's expected

@rjiang 

What is on the rows of your matrix visual

CompanyID and gstClientID

@rjiang 

Then try this

VAR Active =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( 'Usage Data', 'Usage Data'[CompanyID], 'Usage Data'[gstClientID] ),
        "@ClicksLast3Month", [Clicks Last 3 Months]
    ),
    IF ( [@ClicksLast3Month] >= 3, 1, 0 )

Closer, but still not what I'd expect. 

 

I'm noticing that the more fields I add to the summarize function, the higher the counts go. How do I know which fields should be included or excluded?

Do you have anything else on the slicers? Maybe from other tables?

Yes, there are filters on all pages for CompanyName and ProductName

Are these two columns in the same table?

Yes they are columns in the table, but not in the matrix

Ok thebn add the to SUMMARIZE 

Active =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE (
            'Usage Data',
            'Usage Data'[CompanyID],
            'Usage Data'[gstClientID],
            'Usage Data'[CompanyName],
            'Usage Data'[ProductName]
        ),
        "@ClicksLast3Month", [Clicks Last 3 Months]
    ),
    IF ( [@ClicksLast3Month] >= 3, 1, 0 )
)

I tried this and now it seems to be overcounting

Please send sample file. I'll to look into it

Do you have time slicer?

Tou csn also try with CALCULATE 

 

Activew =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( 'Usage Data', 'Usage Data'[CompanyID], 'Usage Data'[gstClientID] ),
        "@ClicksLast3Month", [Clicks Last 3 Months]
    ),
    CALCULATE ( IF ( [@ClicksLast3Month] >= 3, 1, 0 ) )
)

I am expecting 2022-03 in the Active tab to evaluate to a total of 15,825

https://drive.google.com/file/d/1gnQj9E1XgFEZp1zZyS7USlPn88S6vRLv/view?usp=sharing

The only thing which was missing is the Year Month column from the date table. 

Active = 
SUMX (
    ADDCOLUMNS (
        CROSSJOIN (
            SUMMARIZE (
                'Usage Data',
                'Usage Data'[gstClientID],
                'Usage Data'[gstCompanyID]
            ),
            VALUES ( 'Date Lookup'[Year Month] )
        ),
        "ClicksLast3Months", [Clicks Last 3 Months]
    ),
    IF ( [Clicks Last 3 Months] >= 3, 1, 0 )
)

However I was unable to get the numbers you've mentined above

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors