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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-eqin-msft
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
v-eqin-msft
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

v-eqin-msft
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

amitchandak
Super User
Super User

@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] )))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.