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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
montiell
New Member

Compare data from two files and fill a new column?

Hi everybody,

 

I am new to power bi, and I have been requested to create a report for my job. I am currently on the need to find a way of simplifiying my data. Lets say i have a excel csv file with data that contain a column with 107 different sub categories(over 17k entries). This sub categories falls into 8 main categories that I would like to create a new column and somehow create a Dax formula that if the value is equal to VALUE1 or VALUE2 or VALUE3... VALUE107, Fill the new colum with CATEGORY1 or CATEGORY2...CATEGORY8. What I did i have My main report data sheet on power bi and I created another excel file with the Main category and the subcategory and i would like to accomplish the following:

 

If File1 SubCategory Column is equal to File2 SubCategory Column, fill the Main Category value from File2 MainCategory on New column on File1

 

I am not sure if this makes any sense but I do hope it does!

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @montiell ,

 

I created 2 sample table to explain how to realize what you need:

File 1File 1File 2File 2

For question 1,if you wanna create a new column to group by the values,take the steps as below:

Go to query editor>add column>conditional column>then fill in the blanks with your requirement;

Annotation 2020-06-03 100029.pngAnnotation 2020-06-03 100103.png

 

For question 2:

Create a calculated column as below:

 

main category = LOOKUPVALUE('File 2'[main category],'File 2'[subcategory],'File 1'[subcategory],blank())

 

And you will see:

Annotation 2020-06-03 100324.png

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
montiell
New Member

Thank you all for your help!

v-kelly-msft
Community Support
Community Support

Hi @montiell ,

 

I created 2 sample table to explain how to realize what you need:

File 1File 1File 2File 2

For question 1,if you wanna create a new column to group by the values,take the steps as below:

Go to query editor>add column>conditional column>then fill in the blanks with your requirement;

Annotation 2020-06-03 100029.pngAnnotation 2020-06-03 100103.png

 

For question 2:

Create a calculated column as below:

 

main category = LOOKUPVALUE('File 2'[main category],'File 2'[subcategory],'File 1'[subcategory],blank())

 

And you will see:

Annotation 2020-06-03 100324.png

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
mahoneypat
Microsoft Employee
Microsoft Employee

I think what you are describing in a called a Groups column in Power BI.  If so, it's easy.  Please see this article.

https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-grouping-and-binning

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors