Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Retrieve a text value in one column based on MAX in another

I have the following table. There are 8 machine ID's. What I need is a table which shows the color of the maximum last status date/time. So for machine 1 this is the color red, for machine 2 color red, machine 3 color orange...etc. I tried selected value and lookup value together with maximum last status date / time, but don't get the right solution. Please advise! Thanks in advance.

 

 

 

  • Anonymous - Updated. Updated the PBIX as well, attached.

     

    Measure 24 = 
      VAR __Color = MAX('Table (24)'[Machine Status])
      VAR __Laststatus = MAX('Table (24)'[Laststatus])
      VAR __Table = SELECTCOLUMNS(SUMMARIZE(FILTER(ALL('Table (24)'),[Laststatus]=__Laststatus),[Machine ID],"__Last",MAX('Table (24)'[Laststatus])),"__Machine",[Machine Id],"__Last",[__Last])
      VAR __Table1 = 
        ADDCOLUMNS(
          __Table,
          "__Status",
            MAXX(
              FILTER('Table (24)','Table (24)'[Machine ID]=[__Machine] && 'Table (24)'[Laststatus]=[__Last]),
              [Machine Status]
            )
         )
    RETURN
      COUNTROWS(FILTER(__Table1,[__Status] = __Color))

     

18 Replies