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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
neilmc
Frequent Visitor

Joining two tables out of one table -best way

Hello - I have a table which as mulitple customer entries and the date they ordered 

IDCategoryDate
1Food21/02/2023
2Food22/02/2023
3Food23/02/2023
4Food24/02/2023
5Food25/02/2023
6Food26/02/2023
7Food27/02/2023
1Drink28/02/2023
2Drink01/03/2023
3Drink02/03/2023
4Drink03/03/2023
5Drink04/03/2023
6Drink05/03/2023
7Drink06/03/2023
9Drink07/03/2023
10Drink08/03/2023

 

What I am aiming for is to have the customers who only ordered food and then a column with teh date they ordered and a column of the date they ordered drink (if they did) eg: 

IDFood DateDrink Date
121/02/202328/02/2023
222/02/202301/03/2023
323/02/202302/03/2023
424/02/202303/03/2023
525/02/202304/03/2023
626/02/202305/03/2023
727/02/202306/03/2023

 

I did this in the power query editor by creating two tables and usign filter and merge.  I also managed to do it using DAX by creating two tables - one for food customers and one for drink customers (I used selectcolumns to allow me to rename fields so I could join) and then merging the two tables using naturalleftouterjoin

 

As I'm a bit of a novice - is this the best way to do it (and does it matter if I did it in power query editor - which was easier) - any tips appreciated

 

 

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

In Power Query

NewStep=Table.Pivot(PreviousStepName,{"Food","Drink"},"Category","Date",each _{0}?)

in dax

just put the customer id on the row, and category on the column, then put the measure on the value area

Measure=MAX(Table[Date])

View solution in original post

1 REPLY 1
wdx223_Daniel
Super User
Super User

In Power Query

NewStep=Table.Pivot(PreviousStepName,{"Food","Drink"},"Category","Date",each _{0}?)

in dax

just put the customer id on the row, and category on the column, then put the measure on the value area

Measure=MAX(Table[Date])

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.