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
Anonymous
Not applicable

Running Total in Matrix

Hi All,

 

i could able to achieve sum of ll the months.

Provided the example for "sum" of all the columns and we are showing that in right hand side.

 

4.PNG

Is it possible to have running total? Provided the sample output below

5.PNG

 

 

Thanks in Advance

Prakash

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try something like this.

Sales RT = 
IF(
    NOT ISEMPTY( 'Table' ),
    VAR __maxDate = MAX( 'Calendar'[Date] )
    RETURN
    CALCULATE(
        [Sales],
        'Calendar'[Date] <= __maxDate,
        ALL( 'Calendar' )
    )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

8 REPLIES 8
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario.

Table:

a1.png

Then you may create a calculated table and build a one-to-many relationship between two tables as follows.

 

Date Table = CALENDARAUTO()

 

a2.png

 

You can create a measure as below.

Running Total =
CALCULATE(
         SUM('Table'[Value]),
         DATESYTD('Date Table'[Date])
)

 

Finally, you may use matrix visual to show the reslut:

a3.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try something like this.

Sales RT = 
IF(
    NOT ISEMPTY( 'Table' ),
    VAR __maxDate = MAX( 'Calendar'[Date] )
    RETURN
    CALCULATE(
        [Sales],
        'Calendar'[Date] <= __maxDate,
        ALL( 'Calendar' )
    )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Anonymous
Not applicable

Hi @Mariusz ,

 

Can we achieve this without the help of calendar table?

 

Thanks.

 

Also any help n the below would be helpful

https://community.powerbi.com/t5/Desktop/create-measure-based-on-column-values/m-p/903165/highlight/...

Hi @Anonymous 

 

You can replace Calendar Date column with a date column Comming from your table, but using a Date Dimension / Calendar Table is considered the best practice.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Anonymous
Not applicable

Hi @Mariusz 

 

I changed as per your suggestion but it is not working.

Sales RT = 
IF(
    NOT ISEMPTY( 'Table' ),
    VAR __maxDate = MAX( 'Table'[Date] )
    RETURN
    CALCULATE(
        [Sales],
        'Table'[Date] <= __maxDate,
        ALL( 'Table' )
    )
)

 

31.PNG

The counts are not matching.

 

Thanks

Anonymous
Not applicable

Hi,

@Mariusz Thanks for your help.

Actually i forgot to put AllExcept. Now it is woking fine

 

 

Sales RT = 
IF(
    NOT ISEMPTY( 'Table' ),
    VAR __maxDate = MAX( 'Table'[Date] )
    RETURN
    CALCULATE(
        [Sales],
        'Table'[Date] <= __maxDate,
        ALLExcept( 'Table','Table'[Source System] )
    )
)

 

Anonymous
Not applicable

Hi @Mariusz 

I would like to have a rollin 3 months average. will the below code is good? or do we have any better way?

Sales RT = 
IF(
    NOT ISEMPTY( 'Table' ),
    VAR __maxDate = MAX( 'Table'[Date] )
    VAR __minDate = MIN( 'Table'[Date] )-90
    RETURN
    CALCULATE(
        [Sales],
        'Table'[Date] <= __maxDate,'Table'[Date] >= __minDate,
        ALLExcept( 'Table','Table'[Source System] )
    )
)

Thanks 

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.