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
Youness99
Frequent Visitor

Help Flag on column

I am trying to create 2 measures one for flag a and another for flag b, and these measures have to change based on the date range filtered and the appearance of all two flags in the recent date.

 

step1.png

 

 

 

 

 

 

 

So in other words if I apply a filter from 25/02/2023 to 08/03/2023 as in the picture the output of the measure flag A must be 0 in all rows because in the last date 08/03/2023 it does not appear, it appears flag so in the measure flag B must be 1 in all rows because in 08/03/2023 it appears as in the picture.

 

Result expected:

step2.png

 

 

 

 

I can get the flag to change dynamically but only on the last row not all rows of all two measures, I don't know if it is possible to do that with a measure.

 

Thanks.

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1685340358347.png

 

 

Flag A measure expected outcome: =
VAR _slicerlastdate =
    CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
VAR _flagAdate =
    FILTER ( ALL ( 'Calendar'[Date] ), CALCULATE ( MAX ( Data[Flag A] ) ) = "A" )
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[Date] ),
        IF ( _slicerlastdate IN _flagAdate, 1, 0 )
    )

 

Flag B measure expected outcome: = 
VAR _slicerlastdate =
    CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) )
VAR _flagAdate =
    FILTER ( ALL ( 'Calendar'[Date] ), CALCULATE ( MAX ( Data[Flag B] ) ) = "B" )
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[Date] ),
        IF ( _slicerlastdate IN _flagAdate, 1, 0 )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.

Top Solution Authors