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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
zfemmer
Helper I
Helper I

Running Total Measures

I have a few measures that the end user can choose from that will feed into the visuals; WTD, MTD, YTD, last 30 days, etc.

 

The end user has now asked to have the option to see the revenue numbers by day or period to date running total.

 

I have written this:

Test = 
VAR _MaxDate = MAX('Date'[Date])
VAR _MeasureCategory = SELECTEDVALUE(_TimeCompareMeasureCategory[Measure])

VAR _PeriodToDate =
CALCULATE(
    SUM(RevenueChannel[BookedRevenue]),
    'Date'[Date] <= _MaxDate,
        FILTER(ALL('Date'),
        'Date'[Date] < TODAY() &&
        'Date'[Date] >= TODAY() - 7
        )
)
VAR _DayByDay =
CALCULATE (
    SUMX (
        FILTER(
            GROUPBY (
                RevenueChannel,
                RevenueChannel[SearchType],
                RevenueChannel[ChannelType],
                RevenueChannel[ChannelName],
                'Date'[Date],
                'Date'[AccountingWeek],
                'Date'[WeekNumber],
                'Date'[AccountingMonthEnglishAbbrYear],
                'Date'[AccountingMonth],
                'Date'[MonthNumber],
                'Date'[AccountingYear],
                "Revenue", SUMX ( CURRENTGROUP (), RevenueChannel[BookedRevenue] )
            ),
        'Date'[Date] >= TODAY()-7
        && 'Date'[Date] < TODAY()
        ),
    [Revenue]
    )
)
RETURN
SWITCH(
    TRUE(),
    _MeasureCategory = "Day By Day", _DayByDay,
    _MeasureCategory = "Period To Date", _PeriodToDate
)

 

This works except for whatever reason when the end user is selecting period to date it shows up like this:

zfemmer_0-1603129955291.png

How do I get this to only show up to today? It seems to do the calculations up to today, but then just has a static number after that. I need to be able to do this within the measure, not with a slicer.

1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

Just wrap the result inside an if statement 

 

if([some measure that doesn't return a result into the future]<>0,your result)



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

1 REPLY 1
MattAllington
Community Champion
Community Champion

Just wrap the result inside an if statement 

 

if([some measure that doesn't return a result into the future]<>0,your result)



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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