Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Power BI Filter on MAX of a column

My data has a column with the week number. I want a visual (graph in this case) to show the latest week which is the MAX of that value. The visual filter doesn't appear to let me put in the MAX of something, just the usual greater than, less than etc.

I can use a slicer to get the latest week but I want just one visual to show it. The rest of the report will be all weeks.

Any ideas?

like image 338
tonyyeb Avatar asked Sep 15 '25 03:09

tonyyeb


1 Answers

If you only want the data of the latest week in your visual, you can add a calculated column like this:

OnlyLatestWeek = IF('Table1'[Weeknr] = MAX('Table1'[Weeknr]),Table1[Weeknr],BLANK())

Use this column in your visual in stead of the [Weeknr] column.

EDIT
In DirectQuery mode you can try using a measure in stead of a calculated column. Something like this:

OnlyLatestWK = 
VAR maxweek =
    CALCULATE ( MAX ( 'Table1'[Week] ), ALL ( Table1 ) )
RETURN
    IF (
        SELECTEDVALUE ( 'Table1'[Week] ) = maxweek,
        SUM ( Table1[Amount] ), //use your own expression here
        BLANK ()
    )
like image 68
Marco Vos Avatar answered Sep 17 '25 19:09

Marco Vos