Forum Discussion

ansar's avatar
ansar
Icon for Helper II rankHelper II
5 years ago
Solved

MAX & MIN Date measure

Hi am new to power BI, need your support.

 

Am trying to create a measure to get MAX Pstng Date IF Type = "BF" & Agmt Type = "BDA", "Punctual", also IF Type = "BF" & Agmt Type = "Sell out" then MIN of Pstng Date. 

 

Prov Dt =

CALCULATE(
MAXX(Data,ENDOFMONTH(Data[Pstng Date])),Data[Type]="BF")

 

Regards,

Ansar.

 

  • ansar 

    pls try this

    Measure = if(max('Table'[Agmt Type])="Sell Out",CALCULATE(min('Table'[Pstng Date]),FILTER('Table','Table'[Type]="BF")),CALCULATE(max('Table'[Pstng Date]),FILTER('Table','Table'[Type]="BF")))

    one more question, why 24426 is 5/26? i thought you want min date? should that be 4/30?

  • ansar 

    Is this what you want?

    Measure 2 = if(max('Table'[Agmt Type])="Sell Out",EDATE(EOMONTH([Measure],0),6),if(max('Table'[Agmt Type])="BDA",EDATE(date(year([Measure]),12,31),6),if(max('Table'[Agmt Type])="Punctual",EDATE(EOMONTH([Measure],0),12))))

16 Replies

  • ansar 

    is this what you want?

    Measure = if(max('Table'[Type])="BF"&&(max('Table'[Agmt Type])="BDA"||max('Table'[Agmt Type])="Punctual"),CALCULATE(max('Table'[PstingDate]),ALL('Table')),if(max('Table'[Type])="BF"&&max('Table'[Agmt Type])="Sell Out",CALCULATE(min('Table'[PstingDate]),ALL('Table'))))

    • ansar's avatar
      ansar
      Icon for Helper II rankHelper II
      ryan_mayu Appreciate your help, i have followed as below but showing error "The MAX function only accepts a column reference as an argument."
       
      Latest Pstng Dt = IF(MAX(Data[Type]="BF" && (MAX(Data[Agmt Type]="BDA" || MAX(Data[Agmt Type]="Punctual")))),
      CALCULATE(
      MAX(Data[Pstng Date]),ALL(Data)),IF(MAX(Data[Type]="BF" && MAX(Data[Agmt Type]="Sell out")),CALCULATE(MIN(Data[Pstng Date]),ALL(Data))))
       

      Thanks,

      Ansar.

      • ryan_mayu's avatar
        ryan_mayu
        Icon for Super User rankSuper User

        ansar 

        i think you missed the closed braket for max

        atest Pstng Dt = IF(MAX(Data[Type]="BF" )