Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Filter function not working with MAX function

Hi All,

 

I want to calculate the latest outstanding value corresponding to some columns (eg: Age_profile , Status)  provided that the data is for whole of previous week and the file type is OS.

 

I'm using below measure to calculate the outstanding volume 

 

Latest Outstanding =
CALCULATE (
    SUM ( LatestWeek[Volume] ),
    FILTER (
        LatestWeek,
        LatestWeek[WEEK_Commencing_Date] = MAX ( LatestWeek[WEEK_Commencing_Date] )
    ),
    FILTER ( LatestWeek, LatestWeek[File_Type] = "OS" )
)
 
I'm getting wrong results when I'm using MAX function. But if I'm using below function I get right results but that hinders my task as I cannot get previous weeks' data.
 

 

Latest Outstanding =
CALCULATE (
    SUM ( LatestWeek[Volume] ),
    FILTER (
        LatestWeek[LatestWeekCheck]=1
    ),
    FILTER ( LatestWeek, LatestWeek[File_Type] = "OS" )
)
 
Here I've created another column to get the check the latest week . So it gets me data for latest week but no data for previous weeks. 
 
Can Anyone help me ? Thanks in advance 🙂
 
 
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous ,

     

    Measure works on visual level. In the first measure, you used filter(table), so the max() function wouldn't give you the max value for all table but only the max value for the row. You can create a single measure like maxvalue = max(table[column]) to check.

    In that case you may use ALLSELECTED() or ALL() function like below.

    In addition, It's better to share some sample data to us so that we can deal with the DAX for you.

     

    Best Regards,

    Jay

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Measure works on visual level. In the first measure, you used filter(table), so the max() function wouldn't give you the max value for all table but only the max value for the row. You can create a single measure like maxvalue = max(table[column]) to check.

    In that case you may use ALLSELECTED() or ALL() function like below.

    In addition, It's better to share some sample data to us so that we can deal with the DAX for you.

     

    Best Regards,

    Jay