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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ruksuro
Helper III
Helper III

Trend from History Table

Hi Community!

 

Apologies if this has been raised previously or is very simple but I can't seem to find a clear soltuion to the following...

 

Given a source history table (think subscriptions to a service) for can I easily show a count over time as a trend?

 

Table Structure:

Customer ID (int) | Subscribed From (date) | Subscribed Until (date)

 

I want to display a graph which shows the number of active subscriptions over time.

 

The logic (in no particular language) would read as:

 

count(distinct

    IF( [axis date] >= Subscribed From AND

          ( [axis date] < Subscribed Until OR Subscribed Until IS NULL)

    THEN

       Customer ID

    ELSE

        NULL

)      

 

This is possible in Qlikview (bit of a hack) but I'm strugging with PowerBI

 

Any help appreciated, thanks.

 

Harry.

1 ACCEPTED SOLUTION

@Ruksuro,

 

You may refer to the following DAX that creates a new table.

Table =
ADDCOLUMNS (
    CALENDARAUTO (),
    "Count", CALCULATE (
        DISTINCTCOUNT ( Table1[Customer ID] ),
        FILTER (
            Table1,
            Table1[Subscribed From] <= [Date]
                && (
                    Table1[Subscribed Until] > [Date]
                        || ISBLANK ( Table1[Subscribed Until] )
                )
        )
    )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
Ruksuro
Helper III
Helper III

Bump, anyone got any ideas here?

 

Thanks.

@Ruksuro,

 

You may refer to the following DAX that creates a new table.

Table =
ADDCOLUMNS (
    CALENDARAUTO (),
    "Count", CALCULATE (
        DISTINCTCOUNT ( Table1[Customer ID] ),
        FILTER (
            Table1,
            Table1[Subscribed From] <= [Date]
                && (
                    Table1[Subscribed Until] > [Date]
                        || ISBLANK ( Table1[Subscribed Until] )
                )
        )
    )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-chuncz-msft 
I am using this DAX to be able to see how many tickets are open on a particular date.

Except in this formula it currently does not count the ticket that was opened and closed on the same date. Preferably also per department. Please see my topic here  If you could help that'd be great.

Thanks @v-chuncz-msft I have used your recommended DAX, but I can't see how this will work for visualisations.

 

It seems like it just creates a table that counts each time increment for each year. How would you set up the visualisation so that you can identify open subscriptions over different time periods?

 

Cheers.

Anonymous
Not applicable

Thank you for this, @v-chuncz-msft! Worked beautifully.

 

What if I wanted to add another column that showed the number of subscribers that had been with us a year each day?

@v-chuncz-msft

 

i tried this the figures don't much up really and the table begun from 01/01/1899 ??

 

Table =
ADDCOLUMNS (
    CALENDARAUTO();
    "Count"; CALCULATE (
        COUNT ( Merge1[CallID] );
        FILTER (
            Merge1;
            Merge1[NewColumn.DateAssign] <= [Date]
                && (
                   Merge1[NewColumn.DateResolv] > [Date]
                        || ISBLANK ( Merge1[ClosedDate] )
                )
        )
    )
)

Can't say for sure but suspect this is due to your data, please see the following.

 

Link

 

I think autocalendar is doing this...

Thanks for this v-chuncz-msft, worked perfectly.

 

Just for everyone else's information, this solution is not fast (given it's having to count each row multiple times it's not surprising). For a large dataset you might want this info precalculated at source.

 

Very impressed with DAX so far!

 

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.