Price Increase Decrease Flag earliest date

47 views Asked by At

Yesterday (with help) I created this formula for a Price Increase Flag for my report The issue is that the _MinDate that I expect as a result is the one before the first false result, as marked in the pic.

The condition will be IF for the latest date the ANY_PRICE_INC = TRUE, THEN return the ASP for the Min date before the first FALSE.

Not the last or first TRUE in the column, but the first of the consecutive TRUE values only when the most recent is TRUE.

I posted a sample of the data in the table below, the column flag has the result I expect.

Is there a way to do this?

thanks in advance!

enter image description here

enter image description here

Price INC flag =
    VAR __CurrentDate = MAX( 'Sales - Market Level'[DATE] )
    VAR __MaxDate = MAXX(ALLSELECTED('Sales - Market Level'[DATE]),'Sales - Market Level'[DATE])
    VAR __IsTrue = SELECTCOLUMNS(FILTER( ALLSELECTED( 'Sales - Market Level' ), [ANY_PRICE_INC] = TRUE() && [DATE] = __MaxDate ), "__AnyPriceInc", [ANY_PRICE_INC] )
    VAR __MinDate = MINX( FILTER( ALLSELECTED( 'Sales - Market Level'), [ANY_PRICE_INC] = TRUE() ), [DATE] )
    VAR __MinDateRate = MAXX( FILTER( ALLSELECTED( 'Sales - Market Level' ), [ANY_PRICE_INC] = TRUE() && [DATE] = __MinDate ), [ASP] )
    VAR __Result = IF( __IsTrue && __CurrentDate = __MinDate, __MinDateRate, BLANK() )
RETURN
    __Result

DATE ASP ANY_PRICE_DEC ANY_PRICE_INC Flag
8/26/2023 0:00 $49.23 FALSE TRUE
8/19/2023 0:00 $49.65 FALSE TRUE
8/12/2023 0:00 $47.09 FALSE TRUE
8/5/2023 0:00 $48.68 FALSE TRUE
6/24/2023 0:00 $40.66 FALSE TRUE
6/17/2023 0:00 $46.03 FALSE TRUE
6/10/2023 0:00 $47.61 FALSE TRUE
6/3/2023 0:00 $48.60 FALSE TRUE
5/27/2023 0:00 $48.19 FALSE TRUE
5/20/2023 0:00 $45.53 FALSE TRUE
5/13/2023 0:00 $48.08 FALSE TRUE
5/6/2023 0:00 $45.81 FALSE TRUE $45.81
3/25/2023 0:00 $39.15 FALSE FALSE
3/18/2023 0:00 $38.77 FALSE TRUE
3/11/2023 0:00 $39.09 FALSE TRUE
3/4/2023 0:00 $38.52 FALSE FALSE
1/28/2023 0:00 $38.87 FALSE FALSE

The condition will be IF for the latest date the ANY_PRICE_INC = TRUE, THEN return the ASP for the Min date before the first FALSE.

0

There are 0 answers