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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
marquesjef
Regular Visitor

Challenge Creating Cumulative Chart in Power BI with Distinct Token Count

In a table named 'token_ativos' with a column named 'created_at' for dates and a 'token_id' column containing the IDs of active tokens, where the 'created_at' column represents the creation date of the active tokens. In Power BI, I need to create a chart that provides the sum of active tokens for each month. For example, if there were 2 active tokens in February and 2 more were created in March, the chart should display 2 for February and 4 for March. Please create a DAX expression that gives me this cumulative total when placed on the X-axis with 'created_at'.

When I place the distinct count of 'token_id' on the Y-axis and 'created_at' on the X-axis, the chart only returns the count of tokens created each month. I need the cumulative count instead.

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

HI,

I recommend checking out this article by SQLBI: Computing running totals in DAX - SQLBI
Also in February Power BI udate visual calculations are now available in preview. Here is an example video about these: Power BI Feb 2024 Update: Visual Calculations Walkthrough! - YouTube

As for your dax:
var _mdate = max('Calendar'[date)
return
CALCULATE(COUNT('token_ativos'[ 'token_id']), ALL('Calendar'),'Calendar'[date]<= _mdate) 

This assumes ou have calendar table and relation between it and your fact table.

Here is an alternative with YTD.

CALCULATE(COUNT('token_ativos'[ 'token_id']),DATESYTD('Calendar'[date])).

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
v-huijiey-msft
Community Support
Community Support

Hi @marquesjef ,

 

Hope everything is going well.

 

Please follow these steps:

 

1. This is the original data I created.

vhuijieymsft_0-1708503695488.png

 

2. Create a measuring value, the DAX syntax is as follows:

Cumulative Total = 
CALCULATE(
    COUNTROWS('token_ativos'),
    FILTER(
        ALLSELECTED('token_ativos'),
        'token_ativos'[created_at] <= MAX('token_ativos'[created_at])
    )
)

 

3. Put the Created_at on the X-axis and Cumulative Total on the Y-axis.

vhuijieymsft_1-1708503695494.png

 

At this point, you have realized your needs. If you have other questions, please contact me at any time.

 

The pbix file has been attached.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

ValtteriN
Super User
Super User

HI,

I recommend checking out this article by SQLBI: Computing running totals in DAX - SQLBI
Also in February Power BI udate visual calculations are now available in preview. Here is an example video about these: Power BI Feb 2024 Update: Visual Calculations Walkthrough! - YouTube

As for your dax:
var _mdate = max('Calendar'[date)
return
CALCULATE(COUNT('token_ativos'[ 'token_id']), ALL('Calendar'),'Calendar'[date]<= _mdate) 

This assumes ou have calendar table and relation between it and your fact table.

Here is an alternative with YTD.

CALCULATE(COUNT('token_ativos'[ 'token_id']),DATESYTD('Calendar'[date])).

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.