Forum Discussion

Analitika's avatar
Analitika
Post Prodigy
5 years ago
Solved

If date between months

How to write Switch statment if i need determine if date is between months or after date?

 

SWITCH(
TRUE(),
Max(Klients[klient]) = "JSC4" && DATESBETWEEN('Date'[Date],"2017-01","2017-12"), App,
DIVIDE(Percent0,100)
)

 

SWITCH(
TRUE(),
Max(Klients[klient]) = "JSC4" && MAx('Date'[sort_month]) >= "2019-11", 0,
DIVIDE(Percent0,100)
)
  • Hi Analitika ,

     

    Please refer to the measure below:

     

     

    Measure =
    SWITCH (
        TRUE (),
        MAX ( Klients[klient] ) = "JSC4"
            && MAX ( 'Date'[Date] ) <= DATE ( 2017, 12, 31 )
            && MAX ( 'Date'[Date] ) >= DATE ( 2017, 1, 1 ), App,
        MAX ( Klients[klient] ) = "JSC4"
            && MAX ( 'Date'[sort_month] ) / 100
                + MAX ( 'Date'[YEAR] ) >= 2019.11, 0,
        DIVIDE ( Percent0, 100 )
    )

     

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    Best Regards,

    Dedmon Dai

2 Replies

  • Analitika , The information you have provided is not making the problem clear to me. Can you please explain with an example.

     

    I have this column example.

     

    Month Type = Switch( True(),
    Date([Date]) = eomonth(Today(),-1),"Last Month" , //Last Month
    Date([Date])= eomonth(Today(),0),"This Month" , //This Month
    [Month Year]
    )

     

     

    In case of measure , you case >=  and < = Date(2018,01,01) or date from slicer

     

    Month Type = Switch( True(),
    Max(Date([Date])) = eomonth(Today(),-1),"Last Month" , //Last Month
    Max(Date([Date]))= eomonth(Today(),0),"This Month" , //This Month
    [Month Year]
    )


    Appreciate your Kudos.

  • v-deddai1-msft's avatar
    v-deddai1-msft
    Community Support

    Hi Analitika ,

     

    Please refer to the measure below:

     

     

    Measure =
    SWITCH (
        TRUE (),
        MAX ( Klients[klient] ) = "JSC4"
            && MAX ( 'Date'[Date] ) <= DATE ( 2017, 12, 31 )
            && MAX ( 'Date'[Date] ) >= DATE ( 2017, 1, 1 ), App,
        MAX ( Klients[klient] ) = "JSC4"
            && MAX ( 'Date'[sort_month] ) / 100
                + MAX ( 'Date'[YEAR] ) >= 2019.11, 0,
        DIVIDE ( Percent0, 100 )
    )

     

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    Best Regards,

    Dedmon Dai