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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
automated_user
Frequent Visitor

Find value in column and if found get Pseudo and Sum it by Year

Hi all,

 

Is there a way in power query to Find a value in another column, if found get the Pseudo of that row and keep it in a sum by year? For example, I have a table of records for each year and in these records is a column "PartNum". I want to find each instance a value in "PartNum" appears in the column "RowCount.PseudoLines" and if found get the "Pseudo" and keep a running total of that given year (sum). If it is not found, obviously the "SumByYear" column would have '0' as a value for that given "PartNum". See Table below:

 

automated_user_2-1667581896763.png

 

As seen MC55 would have a total sum of 2 for the year "2022" where MC01 was not found in the year "2019", hence had 0. 

 

Thanks

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @automated_user 

 

You can use the Merge Queries feature. First merge the current table to itself. Select "PartNum" and "FiscalYear" in the first table as matching columns (hold on Ctrl key to select multiple columns). Select "RowCount.PseudoLines" and "FiscalYear" in the second table. 

vjingzhang_0-1667810574082.png

 

After merging, click the expand icon on column header of the new table column and switch to Aggregate option. Select "Sum of Pseudo" in the list and click OK to expand. 

vjingzhang_2-1667811140917.png

 

After expanding, you will see null values on not found rows. Select that column and replace null with 0 via Transform > Replace Values. 

vjingzhang_3-1667811421701.png

 

I have attached a demo at bottom. You can download it to see details. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @automated_user 

 

You can use the Merge Queries feature. First merge the current table to itself. Select "PartNum" and "FiscalYear" in the first table as matching columns (hold on Ctrl key to select multiple columns). Select "RowCount.PseudoLines" and "FiscalYear" in the second table. 

vjingzhang_0-1667810574082.png

 

After merging, click the expand icon on column header of the new table column and switch to Aggregate option. Select "Sum of Pseudo" in the list and click OK to expand. 

vjingzhang_2-1667811140917.png

 

After expanding, you will see null values on not found rows. Select that column and replace null with 0 via Transform > Replace Values. 

vjingzhang_3-1667811421701.png

 

I have attached a demo at bottom. You can download it to see details. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors