1

i am stuck on simple performance problem. i have a RunningBalance formula. I have no problem with this formula. It gives me the last nonempty value of balance. (i have the balance on rows.)

Then i try to write another formula with using this formula. Aim is simple. New formula sould show me nothing(BLANK()) when it is <=0

i tried

RunningBalance:=CALCULATE (
    SUM ( DebitsAndCredits[balance]  );
    LASTNONBLANK (
        'Date'[Day];
        CALCULATE ( SUM (DebitsAndCredits[balance] ) )
    )
)

enter image description here

Newformula:=CALCULATE ( IF ( [RunningBalance] <= 0; BLANK (); [RunningBalance] ) )

i wrote this simple formula. But it is very slow when i use DocumentNumber on rows.

How can i make this formula faster?

Cem Üney
  • 25
  • 7

1 Answers1

0

Without variables

I would slightly change the requirement and try to change the IF as:

Newformula:=
MAX(0, [RunningBalance])

Using Variables

A possible enhancement is the following:

RunningBalance:=
VAR _V1 = SUM (DebitsAndCredits[balance] )
RETURN
CALCULATE (
    SUM ( DebitsAndCredits[balance]  );
    LASTNONBLANK (
        'Date'[Day];
        _V1)
    )
)

and,

Newformula:=
VAR _V1 =  [RunningBalance]
RETURN
CALCULATE ( IF ( _V1 <= 0; BLANK (); _V1 ) )

I would also check if the following expression gives you the correct result:

RunningBalance:=
VAR _V1 = SUM (DebitsAndCredits[balance] )
RETURN
CALCULATE (
    _V1;
    LASTNONBLANK (
        'Date'[Day];
        _V1)
    )
)

Otherwise, I would investigate the need of using LASTNONBLANK() and maybe find a different implementation.

Seymour
  • 3,104
  • 2
  • 22
  • 46