Forum Discussion

TDisco's avatar
TDisco
Helper I
3 years ago
Solved

Cumulative Count in Line Graph

Having a issue I can't search a solution for. I've tried others, but I just can't make this work.

 

I have a single Table that contains each time a user logs in. I want to have a yearly cumalitve total on a graph. I can't get them to display over each other - just side-by-side. (when by month)

 

I started with an ALL Cumulative measure--- this works great and restarts at the YEAR mark.

m_LoginsCountYTDAll =
CALCULATE (
    COUNT('tbl_Logins'[UserName] ),
    FILTER (
        ALL ( 'Date' ),
        'Date'[Date] <= MAX ( 'Date'[Date] )
            && 'Date'[Year] = MAX ( 'Date'[Year] )
    )
)
 

I have two measures that divide the counts into two years.

m_LoginsCount2021 = CALCULATE([m_LoginsCountAll], 'Date'[Year] = 2021)
m_LoginsCount2022 = CALCULATE([m_LoginsCountAll], 'Date'[Year] = 2022)
 

Then I have these to get me a cumulative total.

2021

m_LoginsCountYTD2021 =
IF([m_LoginsCount2021] <> 0,
CALCULATE (
    [m_LoginsCount2021],
    FILTER (
        ALLSELECTED ( 'Date' ),
        'Date'[Date] <= MAX ( 'Date'[Date] )
            && 'Date'[Year] = MAX ( 'Date'[Year] )
    )
), "")
 
2022
m_LoginsCountYTD2022 =
IF([m_LoginsCount2022] <> 0,
CALCULATE (
    [m_LoginsCount2021],
    FILTER (
        ALLSELECTED ( 'Date' ),
        'Date'[Date] <= MAX ( 'Date'[Date] )
            && 'Date'[Year] = MAX ( 'Date'[Year] )
    )
), "")
 
All of this works great in a table. When I graph it, it either gives me the above screen shot when by month, or it divides it by year, when I add the year (and month).

 

 

How do I get them to share the same month on the graph (overlap the year)

I'm so close - just missing the mark. Thank you in advance.

3 Replies