cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
justinmpalmer
Frequent Visitor

Cumulative total for Line Chart with Year/Other Slicer Support

I have the following table:

 

justinmpalmer_0-1603911122963.png

I can display a Matrix in PowerBI with the count per week/year, that generates something like:

justinmpalmer_1-1603911264905.png

 

You can see that the weeks for each year are not totaling based on previous weeks results. As an example week 2 for 2018 should show 12.

 

This works with my slicers, but now I need to add a line chart that cumulates the totals to show sales growth per year.  I have searched the forum and can't seem to find the solution. Thoughts?

 

1 ACCEPTED SOLUTION
Eyelyn9
Community Support
Community Support

Hello @justinmpalmer ,

In my opinion, you want to accumulate the count based on the number of weeks each year, don't you?

You can use the following formula:

Measure =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Sales period] = MAX ( 'Table'[Sales period] )
            && 'Table'[Created on Week Number] <= MAX ( 'Table'[Created on Week Number] )
    )
)

My visualization looks like this:

11.4.2.1.PNG

Here's the pbix file.

Have I answered your question? Please mark my answer as a solution. Thanks a lot.
If not, load some insensitive data samples and expected output.

Best regards
Eyelyn Qin

View solution in original post

3 REPLIES 3
Eyelyn9
Community Support
Community Support

Hi @justinmpalmer ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,
Eyelyn Qin

Eyelyn9
Community Support
Community Support

Hello @justinmpalmer ,

In my opinion, you want to accumulate the count based on the number of weeks each year, don't you?

You can use the following formula:

Measure =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Sales period] = MAX ( 'Table'[Sales period] )
            && 'Table'[Created on Week Number] <= MAX ( 'Table'[Created on Week Number] )
    )
)

My visualization looks like this:

11.4.2.1.PNG

Here's the pbix file.

Have I answered your question? Please mark my answer as a solution. Thanks a lot.
If not, load some insensitive data samples and expected output.

Best regards
Eyelyn Qin

View solution in original post

amitchandak
Super User IV
Super User IV

@justinmpalmer , Assume you already have measure and sales_period is year

CALCUALTE([measure], filter(allselected(Table), Table[Created on Week Number] <= max(Table[Created on Week Number]) && Table[_sales_period] =max(Table[_sales_period] )))

 

or

 

CALCUALTE(countrows(Table) ,  filter(allselected(Table), Table[Created on Week Number] <= max(Table[Created on Week Number]) && Table[_sales_period] =max(Table[_sales_period] )))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors