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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mglomb
Frequent Visitor

Get Latest status from multiple columns

Considering that I have a table as per below picture, with case number and count of status of each phase of a process.

I want to check each column and bring the name of the status to a "Latest Status Column" (in yellow in my picture).

Whar formula sould I use in Power Query to do that?Screenshot 2021-11-05 094454.jpg

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@mglomb  it is definitely possible if you have Date as values for Recived, Fixed, Delivered

 

Measure =
VAR _f1 =
    MAX ( 'Table'[Fixed] )
VAR _f2 =
    MAX ( 'Table'[Received] )
VAR _f3 =
    MAX ( 'Table'[Delivered] )
VAR _f4 =
    MAX ( MAX ( _f1, _f2 ), _f3 )
VAR _f6 =
    MAX ( 'Table'[Case] )
VAR _t =
    UNION (
        ADDCOLUMNS (
            SELECTCOLUMNS ( 'Table', "Case", 'Table'[Case], "Date", 'Table'[Fixed] ),
            "Attribute", "Fixed"
        ),
        ADDCOLUMNS (
            SELECTCOLUMNS ( 'Table', "Case", 'Table'[Case], "Date", 'Table'[Delivered] ),
            "Attribute", "Delivered"
        ),
        ADDCOLUMNS (
            SELECTCOLUMNS ( 'Table', "Case", 'Table'[Case], "Date", 'Table'[Received] ),
            "Attribute", "Received"
        )
    )
RETURN
    MAXX ( FILTER ( _t, [Case] = _f6 && [Date] = _f4 ), [Attribute] )

 

smpa01_0-1636121772436.png

 

pbix is attached

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

3 REPLIES 3
smpa01
Super User
Super User

@mglomb  it is definitely possible if you have Date as values for Recived, Fixed, Delivered

 

Measure =
VAR _f1 =
    MAX ( 'Table'[Fixed] )
VAR _f2 =
    MAX ( 'Table'[Received] )
VAR _f3 =
    MAX ( 'Table'[Delivered] )
VAR _f4 =
    MAX ( MAX ( _f1, _f2 ), _f3 )
VAR _f6 =
    MAX ( 'Table'[Case] )
VAR _t =
    UNION (
        ADDCOLUMNS (
            SELECTCOLUMNS ( 'Table', "Case", 'Table'[Case], "Date", 'Table'[Fixed] ),
            "Attribute", "Fixed"
        ),
        ADDCOLUMNS (
            SELECTCOLUMNS ( 'Table', "Case", 'Table'[Case], "Date", 'Table'[Delivered] ),
            "Attribute", "Delivered"
        ),
        ADDCOLUMNS (
            SELECTCOLUMNS ( 'Table', "Case", 'Table'[Case], "Date", 'Table'[Received] ),
            "Attribute", "Received"
        )
    )
RETURN
    MAXX ( FILTER ( _t, [Case] = _f6 && [Date] = _f4 ), [Attribute] )

 

smpa01_0-1636121772436.png

 

pbix is attached

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
jdbuchanan71
Super User
Super User

You can add a custom column like this.

 

= Table.AddColumn(#"Changed Type", "Actual Status", each if [Delievered] = 1 then "Delivered" else 
if [Fix] = 1 then "Fixed" else 
if [Received] = 1 then "Received" else "Other")

You can do this with the conditional column tool as well.

jdbuchanan71_0-1636121041399.png

 

 

jppv20
Solution Sage
Solution Sage

Hi @mglomb ,

 

You can use this formula in PowerQuery:

Actual status =

if [Delivered] = 1 then "Delivered" else
if [Fix] = 1 then "Fixed" else
if [Received] = 1 then "Received" else null

 

If I answered your question, please mark it as a solution to help other members find it more quickly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.