Forum Discussion

GMichaud's avatar
GMichaud
Helper I
5 years ago
Solved

Choose between segment dates and fixed dates based on condition

Hello community!

It seems I can't come up with the right words for my question, so here is a new post for this.

I need to be able to choose between using the minimum and maximum segment dates and using the maximum date minus 30 days depending on the following condition:

DATEDIFF(MIN(dimCalendar(TheDate), MAX(dimCalendar(TheDate), DAY) < 30

If the result is smaller than 30, than I need to use at least 30 days, if not, I need to use the MIN and MAX dates from the segment.

Thanks in advance!

  • GMichaud , Based what I got

    Measure =
    var _1= DATEDIFF(MIN(dimCalendar(TheDate), MAX(dimCalendar(TheDate), DAY)
    return
    if(_1<30, 30, _1)

     

    When you need sum of avg

     

    Measure =
    var _1= DATEDIFF(MIN(dimCalendar(TheDate), MAX(dimCalendar(TheDate), DAY)
    return
    AverageX(values(Table[Segmenr]) , if(_1<30, 30, _1))

1 Reply

  • GMichaud , Based what I got

    Measure =
    var _1= DATEDIFF(MIN(dimCalendar(TheDate), MAX(dimCalendar(TheDate), DAY)
    return
    if(_1<30, 30, _1)

     

    When you need sum of avg

     

    Measure =
    var _1= DATEDIFF(MIN(dimCalendar(TheDate), MAX(dimCalendar(TheDate), DAY)
    return
    AverageX(values(Table[Segmenr]) , if(_1<30, 30, _1))