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

Join 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.

Reply
dwhittaker1
Helper II
Helper II

create new table from existing table with distinct values and no blank

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/2023shoe 
1001/1/2024box
1011/3/2024bed
1011/4/2024spring
1021/7/2024toy

 

 

 

The new table would look like below

 

 

Salesorder      Max Date
1001/1/2024
1011/4/2024
1021/7/2024
1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Simple enough,

ThxAlot_0-1710793136226.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

5 REPLIES 5
ThxAlot
Super User
Super User

Simple enough,

ThxAlot_0-1710793136226.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



kpost
Super User
Super User

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:

 

group by.PNG

 

//Mediocre Power BI Advice,  but it's free//

 

Greg_Deckler
Super User
Super User

@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


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@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.

dwhittaker1_2-1710785655062.png

 

 

 

 

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.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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