Forum Discussion

Colin_Davis's avatar
Colin_Davis
Frequent Visitor
1 year ago
Solved

MAX value with Filter or If

I want to create a New Column that contains True, if this is the higest version for this user, for this course, and the status is completed.  I have the following table called Main:

 

User NameCourse TitleStatusVersionHighest Version
Fred SmithExcel for BeginnersIn Progress6.0 
Fred SmithExcel for Beginners Completed5.0True
Fred SmithExcel for Beginners Completed4.0 
Fred SmithAdvanced ExcelCompleted3.0True
Fred SmithAdvanced ExcelCompleted2.0 
Fred SmithAdvanced ExcelCompleted2.0 
Jane DoeExcel for Beginners Completed5.0True
Jane DoeExcel for Beginners Completed4.0 

 

I want to create the "Highest Version" column that will show the row that is the highest version of each course completed by each user.

 

Thank you.

Colin

  • Colin_Davis , Create a new column using

     

    DAX
    Highest Version =
    VAR CurrentUser = 'Main'[User Name]
    VAR CurrentCourse = 'Main'[Course Title]
    VAR CurrentVersion = 'Main'[Version]
    RETURN
    IF(
    'Main'[Status] = "Completed" &&
    CurrentVersion =
    CALCULATE(
    MAX('Main'[Version]),
    FILTER(
    'Main',
    'Main'[User Name] = CurrentUser &&
    'Main'[Course Title] = CurrentCourse &&
    'Main'[Status] = "Completed"
    )
    ),
    TRUE,
    BLANK()
    )

2 Replies

  • Colin_Davis , Create a new column using

     

    DAX
    Highest Version =
    VAR CurrentUser = 'Main'[User Name]
    VAR CurrentCourse = 'Main'[Course Title]
    VAR CurrentVersion = 'Main'[Version]
    RETURN
    IF(
    'Main'[Status] = "Completed" &&
    CurrentVersion =
    CALCULATE(
    MAX('Main'[Version]),
    FILTER(
    'Main',
    'Main'[User Name] = CurrentUser &&
    'Main'[Course Title] = CurrentCourse &&
    'Main'[Status] = "Completed"
    )
    ),
    TRUE,
    BLANK()
    )

    • Colin_Davis's avatar
      Colin_Davis
      Frequent Visitor

      Thank you, it returns True/False, I don't know why "Blank()" isn't returned, but I can use it.  
      Thank you very much.