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
VendettaBob
Helper II
Helper II

Running Total for a given start and end date

I would like to put 2 running totals for this year and the previous year on the same chart.

My calc for the running total is:

 

CALCULATE (
    [Is SHEQ],
    FILTER (
        ALLSELECTED('EventYearMonth'[DateValue]),
        'EventYearMonth'[DateValue] <= MAX ( 'EventYearMonth'[DateValue])
     && MAX('EventYearMonth'[DateValue]) <= TODAY()  )

 

Rather than having a relative slicer on the visual with "this year". I would like to include it within the calculation. This way I can overlay the previous and current years.

 

Is this possible?

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @VendettaBob ,

I created some data:

vyangliumsft_0-1650953919308.png

Here are the steps you can follow:

1. Create measure.

Measure =
IF(
    YEAR(MAX('Table'[date]))=YEAR(TODAY()),
    CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[date]<=TODAY()&&'Table'[date]>=DATE(YEAR(TODAY()),1,1))),
    IF(
        YEAR(MAX('Table'[date]))=YEAR(TODAY())-1 ,
     CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),
        'Table'[date]>=DATE(YEAR(TODAY())-1,1,1)&&'Table'[date]<=DATE(YEAR(TODAY()),12,31)))))

2. Result:

vyangliumsft_1-1650953919310.png

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @VendettaBob ,

I created some data:

vyangliumsft_0-1650953919308.png

Here are the steps you can follow:

1. Create measure.

Measure =
IF(
    YEAR(MAX('Table'[date]))=YEAR(TODAY()),
    CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[date]<=TODAY()&&'Table'[date]>=DATE(YEAR(TODAY()),1,1))),
    IF(
        YEAR(MAX('Table'[date]))=YEAR(TODAY())-1 ,
     CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),
        'Table'[date]>=DATE(YEAR(TODAY())-1,1,1)&&'Table'[date]<=DATE(YEAR(TODAY()),12,31)))))

2. Result:

vyangliumsft_1-1650953919310.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@VendettaBob , Create a measure like

 

var _max1 = MAX ( 'EventYearMonth'[DateValue])
var _max = date(year(_max1), month(_max1)-12, day(_max1))
var _today = date(year(TODAY()), month(TODAY())-12, day(TODAY()))
return
CALCULATE (
[Is SHEQ],
FILTER (
ALLSELECTED('EventYearMonth'[DateValue]),
'EventYearMonth'[DateValue] <= _max
&& MAX('EventYearMonth'[DateValue]) <= _today ) )

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.