Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kay87
Frequent Visitor

Find min date where continuous 8 rows of data in the calculated measure flag is 1

Hello everyone

 

I have created a measure called "CostFlag" which flags the rows where the "Output" is greater than the "TotalAvg". My queries are:

 

- How to flag continuous 8 rows where the CostFlag is 1

- Find min date of the CostFlag - marked in blue in the image below

 

Please find the screenshot below for your reference.

 

Screenshot.PNG

 

Thanks

Kay

1 ACCEPTED SOLUTION

Hi @kay87

 

Please give this a shot

 

Measure =
VAR mytable1 =
    FILTER ( VALUES ( Table1[Date] ), [CostFlag] = BLANK() )
VAR mytable2 =
    ADDCOLUMNS (
        mytable1,
        "Date Diff", DATEDIFF (
            [Date],
            MINX ( FILTER ( mytable1, [Date] > EARLIER ( Table1[Date] ) ), [Date] ),
            DAY
        )
            - 1
    )
RETURN
    MINX ( FILTER ( mytable2, [Date Diff] >= 8 ), [Date] )
        + 1

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
v-chuncz-msft
Community Support
Community Support

@kay87,

 

You may take a look at this thread.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the link. As I understand this is to add a new column to the data table but I am looking to create a measure to do the above. 

 

Please correct me if I am wrong as I just stared with Power BI and making a transtion from being an advanced user in Qlik to PBI. This could easily be achieved in Qlik by using rangemax function in the straight table.

 

Regards

Kay

Hi @kay87

 

Please give this a shot

 

Measure =
VAR mytable1 =
    FILTER ( VALUES ( Table1[Date] ), [CostFlag] = BLANK() )
VAR mytable2 =
    ADDCOLUMNS (
        mytable1,
        "Date Diff", DATEDIFF (
            [Date],
            MINX ( FILTER ( mytable1, [Date] > EARLIER ( Table1[Date] ) ), [Date] ),
            DAY
        )
            - 1
    )
RETURN
    MINX ( FILTER ( mytable2, [Date Diff] >= 8 ), [Date] )
        + 1

Regards
Zubair

Please try my custom visuals

Help! I'm getting the following error when I create the measure  "Column 'CostFlag' cannot be found or may not be used in this expression."

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.