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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
wayland
Regular Visitor

Select a column based on a variable

Hi everyone!

 

I have been struggulling with the database at work and need some help. My date base consists in a table with a column named after days of the year and if the system is operative or inoperative on that day. Here's a print:

 

wayland_1-1709575471951.png

 

I need to find you if the system is working on the day I'm displaying it. ie: If I open the dashboard on the 12/01, I want to know how many systems are INOP on that day.

I've tried to convert the line in day of the year, creating a variable with the day of the year and using it to remove the column, but I was not successfull, as follows:

 

 

 

 

... continuation of the code ...

    DayOfTheYear = Date.DayOfYear(DateTime.Date(DateTime.LocalNow())),    
    #"Removing all other columns" = Table.SelectColumns(DayOfTheYear, {"ACFT", Number.ToText(DayOfTheYear)}),

... continuation of the code ...

 

 

 

 

What am I doing it wrong?

1 ACCEPTED SOLUTION
dufoq3
Community Champion
Community Champion

Hi @wayland, at step Parameter you can choose column.

Is this what you want?

 

dufoq3_0-1709576968822.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfIPQCJidaKVnGB8Tz8EBZJwxqbaBZdqV6wSsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [System = _t, #"10/01" = _t, #"11/01" = _t, #"12/01" = _t]),
    Parameter = "12/01",
    StepBack = Source,
    RemovedOtherColumns = Table.SelectColumns(StepBack,{"System", Parameter})
in
    RemovedOtherColumns

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

3 REPLIES 3
dufoq3
Community Champion
Community Champion

Hi @wayland, at step Parameter you can choose column.

Is this what you want?

 

dufoq3_0-1709576968822.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfIPQCJidaKVnGB8Tz8EBZJwxqbaBZdqV6wSsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [System = _t, #"10/01" = _t, #"11/01" = _t, #"12/01" = _t]),
    Parameter = "12/01",
    StepBack = Source,
    RemovedOtherColumns = Table.SelectColumns(StepBack,{"System", Parameter})
in
    RemovedOtherColumns

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Thank for the reply @dufoq3 that fixed it! I did not know I needed to do a Step Back

dufoq3
Community Champion
Community Champion

You don't need StepBack because i.e in RemovedOtherColumns I could refer directly to Source, but with StepBack it is easier to read for you 😉


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.