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 would like to create a new table from the existing table below. I would like the table to return distinct salesorder values and the acompanying Max date. I would also like to have the blank value removed from the table.
Salesorder | Max Date | Item |
12/31/2023 | shoe | |
100 | 1/1/2024 | box |
101 | 1/3/2024 | bed |
101 | 1/4/2024 | spring |
102 | 1/7/2024 | toy |
The new table would look like below
Salesorder | Max Date |
100 | 1/1/2024 |
101 | 1/4/2024 |
102 | 1/7/2024 |
Solved! Go to Solution.
Simple enough,
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
I have attached a solution in Power Query:
let
Source = Excel.Workbook(File.Contents("C:\Users\kpost\Downloads\source_table.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Salesorder", Int64.Type}, {"Max Date", type date}, {"Item", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Salesorder] <> null and [Salesorder] <> ""),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Item"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"Salesorder"}, {{"Max_Date", each List.Max([Max Date]), type nullable date}})
in
#"Grouped Rows"
If that doesn't make sense to you I have also attached the power BI file where I made these transformations for you to copy them.
Here's the actual .pbix file where I solved the problem, for you to download and look at it.
https://files.catbox.moe/v226dm.pbix
Basically the steps are:
-Copy the Table
-Filter the first column to remove the blanks
-Delete the third column
-"Group by" using the following settings in Power Query:
//Mediocre Power BI Advice, but it's free//
@dwhittaker1 Maybe:
New Table =
VAR __Table = DISTINCT(SELECTCOLUMNS(FILTER('Table'[SalesOrder]), [Salesorder] <> BLANK()),"__Salesorder", [Salesorder]))
VAR __Table1 =
ADDCOLUMNS(
__Table,
"__MaxDate",
VAR __SO = [__Salesorder]
VAR __Date = MAXX(FILTER('Table',[Salesorder] = __SO), [Max Date])
RETURN
__Date
)
VAR __Result = SELECTCOLUMNS( __Table1, "Salesorder",[__Salesorder],"Max Date", [__MaxDate])
RETURN
__Result
@Greg_Deckler thanks for the the help. I am getting an incorrect syntax error. my data set is in direct query. im not sure if that changes any thing.
FYI to @dwhittaker1
Either @Greg_Deckler or my solution will work, but his is using DAX and mine is using Power Query. It kind of depends on how you want to optimize your Power BI report as to which one you should choose. But for smaller data sets it will not matter which one you choose, practically speaking.
Good luck.
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 |
---|---|
76 | |
71 | |
56 | |
39 | |
35 |
User | Count |
---|---|
66 | |
66 | |
59 | |
53 | |
45 |