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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
jcastr02
Post Prodigy
Post Prodigy

Filter by a Measure

I have this Measure Used in Matrix Table as value because I only want the last week displayed in the matrix, otherwise the category value will show up every week and it’s a bit of an eye sore.   I also have a filter on the page for the HTS Category New, but what happens it is brining values from previous weeks, Is there a way to have this measure show up as a filter since I only want to filter by the latest week.  I also tried to apply a filter on the Category field to only show latest top 1 week but that didn’t work either.  Any help is appreciated.

 

HTS Category_For Matrix =

VAR _maxweek=

    CALCULATE( MAX ( 'Table'[Week] ), ALLSELECTED ('Table' ))

RETURN

    IF (

        SELECTEDVALUE( 'Table'[Week] ) = _maxweek,

        MAX ( 'Table'[HTS Category New] ),

        BLANK ()

    )

Screenshot 2025-01-17 080058.png

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@jcastr02 There is an improved version of your measure that ensures only the latest week's data is displayed:

HTS Category_For Matrix =
VAR _maxweek =
CALCULATE(MAX('Table'[Week]), ALL('Table'))
RETURN
IF(
SELECTEDVALUE('Table'[Week]) = _maxweek,
MAX('Table'[HTS Category New]),
BLANK()
)

 

And then create a new measure to identify the latest week:

LatestWeekFlag =
VAR _maxweek =
CALCULATE(MAX('Table'[Week]), ALL('Table'))
RETURN
IF(MAX('Table'[Week]) = _maxweek, 1, 0)

 

Add the LatestWeekFlag measure to your matrix visual.
Set the filter condition to show only where LatestWeekFlag is 1.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
bhanu_gautam
Super User
Super User

@jcastr02 There is an improved version of your measure that ensures only the latest week's data is displayed:

HTS Category_For Matrix =
VAR _maxweek =
CALCULATE(MAX('Table'[Week]), ALL('Table'))
RETURN
IF(
SELECTEDVALUE('Table'[Week]) = _maxweek,
MAX('Table'[HTS Category New]),
BLANK()
)

 

And then create a new measure to identify the latest week:

LatestWeekFlag =
VAR _maxweek =
CALCULATE(MAX('Table'[Week]), ALL('Table'))
RETURN
IF(MAX('Table'[Week]) = _maxweek, 1, 0)

 

Add the LatestWeekFlag measure to your matrix visual.
Set the filter condition to show only where LatestWeekFlag is 1.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam THANK YOU!!!! this worked!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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