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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
fredsp
Frequent Visitor

Cumulative values - Sum of -> Count of with Strings

Hi,

 

I have a data set of issues reported in a project in Jira and I'm extracting Created Date and each Key (a unique number for each issues reported). I plot Count of Keys with Created Date to get a graph on how many issues are created each day, however now my problem.

 

I would also like to plot the cumulative value for each Created Date but since Key-value is a string I run into problem with my DAX-function.

Anyone out there who knows how to do a SUM of Count of per Created Date so that I can plot the cumulative values instead?

 

Br,

Fredrik

1 ACCEPTED SOLUTION
cosm
Resolver II
Resolver II

Hi @fredsp 
Here is a solution for your problem using example date. 
Please mark as accepted if it solves your problem 🙂

You want plot cumulative count (of distinct distinct keys) pr date.

Here is a solution for computing cumulative distinct counts pr date:

0) Generate sample data

Jira = 
DATATABLE (
    "Key", STRING, 
    "Created DateTime", DATETIME,
    {
        { "1", "2022-01-01 00:00:00" },
        { "2", "2022-01-01 12:34:56" },
        { "3", "2022-01-01 23:59:59" },
        { "4", "2022-01-02 07:00:00" },
        { "5", "2022-01-02 14:30:45" },
        { "6", "2022-01-03 20:15:30" },
        { "7", "2022-01-03 11:11:11" },
        { "8", "2022-01-04 18:45:22" },
        { "9", "2022-01-05 02:22:33" },
        { "10", "2022-01-6 15:55:44" }
    }
)


Add column Created Date with date part of DateTime column:

Created Date = DATE(
    YEAR(Jira[Created DateTime]),
    MONTH(Jira[Created DateTime]),
    DAY(Jira[Created DateTime])
)


See snippet below:

cosm_0-1687422330036.png

 


1) Create a summarized table with count pr date:
In Power BI Model Pane, select "New Table" and add the following DAX statement:

Count pr created date = SUMMARIZE(
Jira,
Jira[Created Date],
"Distinct keys", DISTINCTCOUNT(Jira[Key])
)

 
2) Add cumulative count as ameasure:

Cumulative Count = 
CALCULATE (
    SUM ( 'Count pr created date'[DISTINCT KEYS]),
    FILTER ( ALL ( 'Count pr created date' ), 
    'Count pr created date'[Created date] <= MAX
     ( 'Count pr created date'[Created date] ) )
)

 

cosm_1-1687422514698.png

cosm_2-1687422530757.png

( Filter statement includes all row less than or equal to maximum created date in current filter context)

Done 😀

Now you can use your measure to plot cumulative count as shown below:

cosm_3-1687422792676.png

 




Kind regards!

View solution in original post

4 REPLIES 4
fredsp
Frequent Visitor

Once again, thanks a lot!!

 

fredsp_1-1687436328699.png

 

fredsp
Frequent Visitor

Thanks a lot @cosm for your support. I'll try this out 😊

Nice - let me now if you run into trouble.

Please mark as solution if the solution solves your problem.

Kudos also appreciated.

cosm
Resolver II
Resolver II

Hi @fredsp 
Here is a solution for your problem using example date. 
Please mark as accepted if it solves your problem 🙂

You want plot cumulative count (of distinct distinct keys) pr date.

Here is a solution for computing cumulative distinct counts pr date:

0) Generate sample data

Jira = 
DATATABLE (
    "Key", STRING, 
    "Created DateTime", DATETIME,
    {
        { "1", "2022-01-01 00:00:00" },
        { "2", "2022-01-01 12:34:56" },
        { "3", "2022-01-01 23:59:59" },
        { "4", "2022-01-02 07:00:00" },
        { "5", "2022-01-02 14:30:45" },
        { "6", "2022-01-03 20:15:30" },
        { "7", "2022-01-03 11:11:11" },
        { "8", "2022-01-04 18:45:22" },
        { "9", "2022-01-05 02:22:33" },
        { "10", "2022-01-6 15:55:44" }
    }
)


Add column Created Date with date part of DateTime column:

Created Date = DATE(
    YEAR(Jira[Created DateTime]),
    MONTH(Jira[Created DateTime]),
    DAY(Jira[Created DateTime])
)


See snippet below:

cosm_0-1687422330036.png

 


1) Create a summarized table with count pr date:
In Power BI Model Pane, select "New Table" and add the following DAX statement:

Count pr created date = SUMMARIZE(
Jira,
Jira[Created Date],
"Distinct keys", DISTINCTCOUNT(Jira[Key])
)

 
2) Add cumulative count as ameasure:

Cumulative Count = 
CALCULATE (
    SUM ( 'Count pr created date'[DISTINCT KEYS]),
    FILTER ( ALL ( 'Count pr created date' ), 
    'Count pr created date'[Created date] <= MAX
     ( 'Count pr created date'[Created date] ) )
)

 

cosm_1-1687422514698.png

cosm_2-1687422530757.png

( Filter statement includes all row less than or equal to maximum created date in current filter context)

Done 😀

Now you can use your measure to plot cumulative count as shown below:

cosm_3-1687422792676.png

 




Kind regards!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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