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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ArmellA
Frequent Visitor

Slicer filtering measure on specific date

Hello 🙂 

 

I'm trying to track employee changes between 2 dates. I build measures to do this, and it works fine. but they are not dynamic with any slicers I want to add. Here is an example. I guess I'm just doing this wrong from the beginning, but I don't know how to handle this case. 

 

 

ArmellA_0-1676478687556.png

 

 

 

 
 
My data: 
 
IDNameDateCategorieRegion
1Adam Lister2020-01ProfessionalSouth
1Adam Lister2020-02ITSouth
1Adam Lister2020-03ITSouth
2Suzie White2020-03ITNorth
2Suzie White2020-04ITNorth
2Suzie White2020-05ProfessionalSouth
3Mike Right2020-01ProfessionalSouth
3Mike Right2020-03ITNorth
3Mike Right2020-04ITNorth
3Mike Right2020-05ProfessionalNorth
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @ArmellA ,

Please refer to my pbix file to see if it helps you.

Create a table included the category column.

Create a measure.

Measure =
VAR _mindate =
    MINX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        'Table'[Date]
    )
VAR _1 =
    MINX ( FILTER ( ALL ( 'Table' ), 'Table'[Date] = _mindate ), 'Table'[Region] )
VAR _maxdate =
    MAXX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        'Table'[Date]
    )
VAR _2 =
    MINX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = _maxdate
                && 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] )
        ),
        'Table'[Region]
    )
VAR _re =
    IF ( _1 = "South" && _2 = "North", 1, 0 )
RETURN
    IF (
        _re = 1
            && MAX ( 'Table'[Categorie] ) = SELECTEDVALUE ( 'Table (2)'[category] ),
        1,
        0
    )

Then filter the measure is 1.

vpollymsft_0-1676615397965.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 

View solution in original post

tamerj1
Super User
Super User

Hi @ArmellA 
Please refer to attached sample file with the solution

1.png

From North to South = 
SUMX (
    VALUES ( Employee[ID] ),
    VAR CurrentEmpTable = CALCULATETABLE ( Employee )
    VAR FirstRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], ASC ), Employee[Region] )
    VAR LastRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], DESC ), Employee[Region] )
    RETURN
        IF (  FirstRegion = "North" && LastRegion= "South", 1 )
)
From South to North = 
SUMX (
    VALUES ( Employee[ID] ),
    VAR CurrentEmpTable = CALCULATETABLE ( Employee )
    VAR FirstRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], ASC ), Employee[Region] )
    VAR LastRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], DESC ), Employee[Region] )
    RETURN
        IF (  FirstRegion = "South" && LastRegion= "North", 1 )
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @ArmellA 
Please refer to attached sample file with the solution

1.png

From North to South = 
SUMX (
    VALUES ( Employee[ID] ),
    VAR CurrentEmpTable = CALCULATETABLE ( Employee )
    VAR FirstRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], ASC ), Employee[Region] )
    VAR LastRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], DESC ), Employee[Region] )
    RETURN
        IF (  FirstRegion = "North" && LastRegion= "South", 1 )
)
From South to North = 
SUMX (
    VALUES ( Employee[ID] ),
    VAR CurrentEmpTable = CALCULATETABLE ( Employee )
    VAR FirstRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], ASC ), Employee[Region] )
    VAR LastRegion = MAXX ( TOPN ( 1, CurrentEmpTable, Employee[Date], DESC ), Employee[Region] )
    RETURN
        IF (  FirstRegion = "South" && LastRegion= "North", 1 )
)
Anonymous
Not applicable

Hi @ArmellA ,

Please refer to my pbix file to see if it helps you.

Create a table included the category column.

Create a measure.

Measure =
VAR _mindate =
    MINX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        'Table'[Date]
    )
VAR _1 =
    MINX ( FILTER ( ALL ( 'Table' ), 'Table'[Date] = _mindate ), 'Table'[Region] )
VAR _maxdate =
    MAXX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        'Table'[Date]
    )
VAR _2 =
    MINX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = _maxdate
                && 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] )
        ),
        'Table'[Region]
    )
VAR _re =
    IF ( _1 = "South" && _2 = "North", 1, 0 )
RETURN
    IF (
        _re = 1
            && MAX ( 'Table'[Categorie] ) = SELECTEDVALUE ( 'Table (2)'[category] ),
        1,
        0
    )

Then filter the measure is 1.

vpollymsft_0-1676615397965.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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