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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jfox61
Frequent Visitor

Running totals showing in my graph after today

I have a graph:

jfox61_0-1679935014633.png

 

It seems like this should be so easy, maybe a filter on my graph? I have researched quite a bit and have found no easy way to do this. Can you please help?

9 REPLIES 9
Greg_Deckler
Super User
Super User

@jfox61 Add this to your measure:

RETURN

  IF( MAX('Date'[Date] > TODAY(), BLANK(), __Result)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

So I tried to create a new measure:

Before Today = RETURN IF( MAX('Registrations'[Date] <= TODAY(), BLANK(), __Result))
 
and am getting a syntax error:
The syntax for 'RETURN' is incorrect. (DAX(RETURN IF( MAX('Registrations'[Date] <= TODAY(), BLANK(), __Result)))).
 
Which I should be able to figure out but ......

Hi Greg,

Thank you and now another question, do I add this:

RETURN

  IF( MAX('Date'[Date] > TODAY(), BLANK(), __Result)

 

to my running total measure? If so where, at the end? I know this is annoying very beginner-ish!

 

Count of Unit running total in Month =
CALCULATE(
    COUNTA('Registrations'[Unit]),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE(
                'Registrations',
                'Registrations'[Date].[MonthNo],
                'Registrations'[Date].[Month]
            ),
            ALLSELECTED('Registrations')
        ),
        ISONORAFTER(
            'Registrations'[Date].[MonthNo], MAX('Registrations'[Date].[MonthNo]), DESC,
            'Registrations'[Date].[Month], MAX('Registrations'[Date].[Month]), DESC
        )
    )
)

@jfox61 Yes, like this:

Count of Unit running total in Month =
VAR __Result = 
CALCULATE(
    COUNTA('Registrations'[Unit]),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE(
                'Registrations',
                'Registrations'[Date].[MonthNo],
                'Registrations'[Date].[Month]
            ),
            ALLSELECTED('Registrations')
        ),
        ISONORAFTER(
            'Registrations'[Date].[MonthNo], MAX('Registrations'[Date].[MonthNo]), DESC,
            'Registrations'[Date].[Month], MAX('Registrations'[Date].[Month]), DESC
        )
    )
)
RETURN
  IF( MAX('Date'[Date] > TODAY(), BLANK(), __Result)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Oh my gosh thank you for coming back!

So I added:

Count of Unit running total in Month =
CALCULATE(
    COUNTA('Registrations'[Unit]),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE(
                'Registrations',
                'Registrations'[Date].[MonthNo],
                'Registrations'[Date].[Month]
            ),
            ALLSELECTED('Registrations')
        ),
        ISONORAFTER(
            'Registrations'[Date].[MonthNo], MAX('Registrations'[Date].[MonthNo]), DESC,
            'Registrations'[Date].[Month], MAX('Registrations'[Date].[Month]), DESC

        )
    )
) RETURN
  IF(MAX('Date'[Date] > TODAY(), BLANK(),__Result)
 
Didn't work
 
So I changed the statement to 
RETURN
  IF(MAX('Date'[Month] > TODAY(), BLANK(),__Result) - at the end
 
And then finally below
Count of Unit running total in Month =
CALCULATE(
    COUNTA('Registrations'[Unit]),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE(
                'Registrations',
                'Registrations'[Date].[MonthNo],
                'Registrations'[Date].[Month]
            ),
            ALLSELECTED('Registrations')
        ),
        ISONORAFTER(
            'Registrations'[Date].[MonthNo], MAX('Registrations'[Date].[MonthNo]), DESC,
            'Registrations'[Date].[Month], MAX('Registrations'[Date].[Month]), DESC

        )
    )
) RETURN
  IF(MAX('Date'[MonthNo] > TODAY(), BLANK(),__Result)
 
And I'm getting big fat syntax errors. I have tried multiple things, nothing works.
jfox61_0-1680275019965.png

 

Thank you, thank you

@jfox61 You're missing your VAR definition. To use a RETURN statement you need a VAR statement. Check the code I posted again. It's the second line of the code. If you really want to (although I highly recommend against it) you could do it without the VAR and RETURN. But you really should use VAR's because they help break up your code into manageable chunks that you can debug using things like TOCSV, etc.

 

Count of Unit running total in Month =
IF( MAX('Date'[Date] > TODAY(), BLANK(),
CALCULATE(
    COUNTA('Registrations'[Unit]),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE(
                'Registrations',
                'Registrations'[Date].[MonthNo],
                'Registrations'[Date].[Month]
            ),
            ALLSELECTED('Registrations')
        ),
        ISONORAFTER(
            'Registrations'[Date].[MonthNo], MAX('Registrations'[Date].[MonthNo]), DESC,
            'Registrations'[Date].[Month], MAX('Registrations'[Date].[Month]), DESC
        )
    )
)
)

Another thing, there is far easier syntax to create a running total: Better Running Total - Microsoft Power BI Community

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

I'm really trying here, I swear. 

I tried your simpler version to no avail. I got syntax errors there too so it's something that I am doing....

 

I tried this code:

Count of Unit running total in Month =
VAR _RESULT =
CALCULATE(
COUNTA('Registrations'[Unit]),
FILTER(
CALCULATETABLE(
SUMMARIZE(
'Registrations',
'Registrations'[Date].[MonthNo],
'Registrations'[Date].[Month]
),
ALLSELECTED('Registrations')
),
ISONORAFTER(
'Registrations'[Date].[MonthNo], MAX('Registrations'[Date].[MonthNo]), DESC,
'Registrations'[Date].[Month], MAX('Registrations'[Date].[Month]), DESC
)
)
)
RETURN IF( MAX('Date'[Date] > TODAY(), BLANK(), _RESULT))

 

in the DAX Formatter on-line, it points to the parens by Blank.. well here is a screenshot:

jfox61_0-1680292471860.png

The syntax error I get in Power BI says there are too many arguments. 

Thank you for the information sorry I didn't read your code in full! I am still getting a syntax error that says "Too many arguments were passed to the MAX function. The maximum argument count for the function is 2."

 

My Code

Count of Unit running total in Month = VAR _RESULT = CALCULATE(
    COUNTA('Registrations'[Unit]),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE(
                'Registrations',
                'Registrations'[Date].[MonthNo],
                'Registrations'[Date].[Month]
            ),
            ALLSELECTED('Registrations')
        ),
        ISONORAFTER(
            'Registrations'[Date].[MonthNo], MAX('Registrations'[Date].[MonthNo]), DESC,
            'Registrations'[Date].[Month], MAX('Registrations'[Date].[Month]), DESC

        )
    )
) RETURN  IF( MAX('Date'[Date] > TODAY(), BLANK(), _RESULT))
 
I will look at the video you sent me, thank you. This code came from using the quick measure for running total.
jfox61
Frequent Visitor

This is my date setup

jfox61_0-1680275425859.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.