Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a date table that includes index columns for current day, current week, current month, etc. Here's how my date table looks:
[Date]
Date ID | Current Day Index | Current Week Index | Current Month Index |
20220614 | 0 | 1 | 1 |
20220615 | 0 | 1 | 1 |
20220616 | 1 | 1 | 1 |
I want to create a new table that will have every single date for each index column that equals 1. For example, June 16th (today), is the current day, within the current week, and within the current month-- so I should have 3 instances of today's date along with the "Timeframe" description in the other column. Example of how my table should look:
[Date Hierarchy]
Date ID | Timeframe |
20220614 | Current Week |
20220614 | Current Month |
20220615 | Current Week |
20220615 | Current Month |
20220616 | Current Week |
20220616 | Current Month |
20220616 | Current Day |
Am I able to build something like this using the "New Table" option and building it via DAX formulas?
Solved! Go to Solution.
Hi @jludwick ,
You simply need to unpivot all columns except the date ID column, and then filter out values in column value that are <> 1.
Here is the sample M-code. you can copy and paste this into a blank query and see all the steps in detail.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjIwMzRR0lEyAGJDMI7VgUuY4pIwgwuCJWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date ID" = _t, #"Current Day Index" = _t, #"Current Week Index" = _t, #"Current Month Index" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date ID", Int64.Type}, {"Current Day Index", Int64.Type}, {"Current Week Index", Int64.Type}, {"Current Month Index", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date ID"}, "Attribute", "Value"),
#"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = 1)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Value"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Attribute", "Timeframe"}})
in
#"Renamed Columns"
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
Hi @jludwick ,
You simply need to unpivot all columns except the date ID column, and then filter out values in column value that are <> 1.
Here is the sample M-code. you can copy and paste this into a blank query and see all the steps in detail.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjIwMzRR0lEyAGJDMI7VgUuY4pIwgwuCJWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date ID" = _t, #"Current Day Index" = _t, #"Current Week Index" = _t, #"Current Month Index" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date ID", Int64.Type}, {"Current Day Index", Int64.Type}, {"Current Week Index", Int64.Type}, {"Current Month Index", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date ID"}, "Attribute", "Value"),
#"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = 1)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Value"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Attribute", "Timeframe"}})
in
#"Renamed Columns"
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
Thank you Rohit!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
65 | |
63 | |
52 | |
37 | |
36 |
User | Count |
---|---|
82 | |
67 | |
61 | |
46 | |
45 |