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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JakeandSnake
Frequent Visitor

To Show the latest Status based on Columns Value

Hi Experts,

 

I have one table as below:

JakeandSnake_1-1629709448488.png

Conditions:

1. In reality, I have thousands of projects. More than 500K rows. 

2. I have a lot of steps, could be 30 steps columns.

 

Expectation:

I want to have a column to show the farthest step name with the value "TRUE", something like below. Basically to show the latest status of each project.

JakeandSnake_2-1629709799103.png

Anyone can help? 

Thanks in advance. 

 

1 ACCEPTED SOLUTION

Hey @JakeandSnake ,

 

for the example you provided it worked 😉

Rename the columns to give the step an order and put the number first, then it will work:

selimovd_0-1629714980488.png

 

And the result:

selimovd_1-1629715011494.png

 

When you have more than 10 columns make sure you have the same amount of numbers at the beginning everywhere:

selimovd_2-1629715197108.png

 

selimovd_3-1629715216528.png

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

4 REPLIES 4
selimovd
Super User
Super User

Hey @JakeandSnake ,

 

that's possible in Power Query. For that unpivot the other columns, remove the FALSE ones and then GROUP BY the MAX of the Status column.

Check my example:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnR0VNJRCgkKdcWg3Bx9gl2VYnWilZycnOB8XDRInbOzMy7DwBRIjYuLCw6b4CbFAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, #"Step 1" = _t, #"Step 2" = _t, #"Step 3" = _t, #"Step 4" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"Step 1", type logical}, {"Step 2", type logical}, {"Step 3", type logical}, {"Step 4", type logical}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Project"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = true)),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Project"}, {{"MaxStep", each List.Max([Attribute]), type text}})
in
    #"Grouped Rows"

 

In my example the initial table looks like this:

selimovd_0-1629710964011.png

 

And the final result will look like this:

selimovd_1-1629710997187.png

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi @selimovd ,

 

Thanks for your advice. 

I assume your last step is to group by the MAX of the "Attribute" column. 

And I guess it works because the status columns are named sequentially " Step 1", Step 2"...

However, when I tried mine, which status columns are totally words like "Step ABC", "Step BCD"...The results were not accurate. Any idea? 

Hey @JakeandSnake ,

 

for the example you provided it worked 😉

Rename the columns to give the step an order and put the number first, then it will work:

selimovd_0-1629714980488.png

 

And the result:

selimovd_1-1629715011494.png

 

When you have more than 10 columns make sure you have the same amount of numbers at the beginning everywhere:

selimovd_2-1629715197108.png

 

selimovd_3-1629715216528.png

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Thanks~ It works for me now!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.