Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Integrate a condition in a VAR Function

Hello everyone,

 

I would like to integrate a IF in the RETURN of a VAR expression. I explain myself, 

 

This is my current fonction VAR (without the IF): 

 

To Year End = 
VAR StartingDate = FIRSTDATE ( 'Dates'[Date] )
VAR EndingDate = DATE ( YEAR ( StartingDate ), 12, 31 )

RETURN
    CALCULATE(
        [Projection],
        'Dates'[Date] >= StartingDate  && 'Dates'[Date] <= EndingDate

 But I would like to integrate in the calculate a IF. That is to say, 

 

RETURN

IF(day(today())<=8; CALCULATE([Projection],'Dates'[Date] >= StartingDate && 'Dates'[Date] <= EndingDate.

 

Could you please help me because it does not accept the IF. Thanks you.

3 Replies

  • Anonymous try following. also can you share what error message you are getting

     

    To Year End = 
    VAR StartingDate = FIRSTDATE ( 'Dates'[Date] )
    VAR EndingDate = DATE ( YEAR ( StartingDate ), 12, 31 )
    
    RETURN
    IF ( DAY( TODAY() ) <= 8,
        CALCULATE(
            [Projection],
            'Dates'[Date] >= StartingDate , 'Dates'[Date] <= EndingDate
    )
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello parry2k ;

       

      There is no error message. The graphic is just empty. I tried your proposition and it does not work. Do you know an alternative. 

       

      Thanks you

      • parry2k's avatar
        parry2k
        Super User

        Anonymous can you share sample pbix file, remove any sensitive information before sharing.