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
JanSimunek
New Member

Number of users who made more than 12 requests last year

Hello,

 

I have a problem with a task where I need to count number of users who did a task last year at least 12 times (not including 12) who are called heavy active users. My current formula looks like this:

 

Heavy Active Users =
VAR tableVar =
ADDCOLUMNS
(
    FILTER
    (
        SUMMARIZE
        (
            Conversions, Conversions[user_pseudo_id], "Count records", COUNT
            (
                Conversions[user_pseudo_id]
            )
        ), [Count records] > 12
    ), "aCol", 1
)

VAR SumUser = SUMX
(
    tableVar, [aCol]
)

VAR Res = IF
(
    ISBLANK
    (
        CALCULATE
        (
            SumUser, DATESINPERIOD
            (
                'Calendar'[Date], DATEADD
                (
                    LASTDATE
                    (
                        Conversions[event_timestamp - Full Date]
                    ), -364, DAY
                ),
            365, DAY)
        )
    ) = TRUE, CALCULATE
    (
        SumUser, DATESINPERIOD
        (
            'Calendar'[Date], DATEADD
            (
                LASTDATE
                (
                    Conversions[event_timestamp - Full Date]
                ), -363, DAY
            ),
        364, DAY
        )
    ), CALCULATE
    (
        SumUser, DATESINPERIOD
        (
            'Calendar'[Date], DATEADD
            (
                LASTDATE
                (
                    Conversions[event_timestamp - Full Date]
                ),
            -364, DAY
            ),
        365, DAY
        )
    )
)
RETURN Res
 
The IF function is used because one day there was no request and it caused negative values in the chart for another measure. The problem is that this formula only counts users who made a request in the current week (as in the column in the chart). I need to count all users who sent more than 12 requests in the whole last year, which means if there was a user who sent 13 requests 11 months ago and no other since then, he must be included in the heavy active users.
I got a recommendation to use WINDOW function instead but I got no results. Do you have any ideas?
1 REPLY 1
amitchandak
Super User
Super User

@JanSimunek , Create a measures like

 

Rolling 12 = CALCULATE(countrows(Table),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

// use TI previous year,if you need that

 

Then have meausre like

 

Countx(Values(User[USer ID]), if([Rolling 12] >12, [User], blank())

 

 

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.