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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AppleMan
Helper III
Helper III

Creating Table Row with data from two rows using matching criteria

I have an interesting ask that I have a few solutions in my head for how to accomplish it but before I go ahead I would like to see what others would suggest for accomplishing this.

 

Basically, I have a report that is comparing data from two different jobs. To do this I have the user select two jobs from a slicer and then am using MAX() and MIN() in my measures to grab either job 1 (the MIN) or job 2 (the MAX). 

 

One of the visuals I would like on this page is a table that has the Job and the estimated hours vs actual hours of work. But instead of having this and then needing to scroll to find the other job to compare I would like both jobs to show in one row. I need to either write measures and use those in the table or create a calculated table that does this. 

 

Here is an example of my current table:

This is job 1:

AppleMan_0-1725378400116.png

 

This is job 2 (found from just scrolling further in the table):

AppleMan_1-1725378445099.png

 

What I would like to show is all the data in the first image, then where the assembly and operation match for the second job show that data in the same line. 

 

Here is one row as an example using the data in the images above (this is for assembly 0, operation 10 for both jobs):

10593 | 0 | 10 | PLS | 20.00 | 28.80 | 0.00 | 11069 | 0 | 10 | PLS | 30.00 | 71.84 | 2.35

 

What would be the suggested best method to accomplish this?

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @AppleMan ,

I created some data:

vyangliumsft_0-1725525502219.png

 

Here are the steps you can follow:

1. Create calculated table.

Slicer_Table =
DISTINCT('Table'[Job])

vyangliumsft_1-1725525502221.png

2. Create measure.

Flag =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
return
IF(
    MAX('Table'[Job])=_min,1,0)
Actual Hours_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
retur
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Actual Hours])
Assembly_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
retur
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=1&&[Job]=_max),[Assembly])
Code_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
MAXX(
    FILTER(ALL('Table'),'Table'[group_index]=1&&[Job]=_max),[Code])
Estimated Hours_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Estimated Hours])
Job_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Job])
Operation_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Operation])
Rework Hours_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Rework Hours])

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1725525534673.png

4. Result:

vyangliumsft_3-1725525534681.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @AppleMan ,

I created some data:

vyangliumsft_0-1725525502219.png

 

Here are the steps you can follow:

1. Create calculated table.

Slicer_Table =
DISTINCT('Table'[Job])

vyangliumsft_1-1725525502221.png

2. Create measure.

Flag =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
return
IF(
    MAX('Table'[Job])=_min,1,0)
Actual Hours_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
retur
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Actual Hours])
Assembly_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
retur
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=1&&[Job]=_max),[Assembly])
Code_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
MAXX(
    FILTER(ALL('Table'),'Table'[group_index]=1&&[Job]=_max),[Code])
Estimated Hours_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Estimated Hours])
Job_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Job])
Operation_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Operation])
Rework Hours_Measure =
var _min=MINX(ALLSELECTED('Slicer_Table'),[Job])
var _max=MAXX(ALLSELECTED('Slicer_Table'),[Job])
return
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=_max),[Rework Hours])

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1725525534673.png

4. Result:

vyangliumsft_3-1725525534681.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Hi  @AppleMan ,

 

Here are the steps you can follow:

Way1: Use meausre to display the corresponding columns

In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1725417434078.png

Create calculated column.

group_index =
RANKX(
    FILTER(ALL('Table'),
    'Table'[Job]=EARLIER('Table'[Job])),[Index],,ASC)

vyangliumsft_1-1725417434081.png

Create measure.

Job_Measure =
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=11069),[Job])
Actual Hours_Measure =
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=11069),[Actual Hours])
Operation_Measure =
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=11069),[Operation])
Estimated Hours_Measure =
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=11069),[Estimated Hours])
Rework Hours_Measure =
SUMX(
    FILTER(ALL('Table'),'Table'[group_index]=MAX('Table'[group_index])&&[Job]=11069),[Rework Hours])

Set [Job] -- 10593

vyangliumsft_2-1725417462207.png

Result:

vyangliumsft_3-1725417462211.png

Way2:Add the data as a new column:

Copy Table twice - Table10593 and Table11069

vyangliumsft_4-1725417523867.png

For Table10593 filter only 10593 of the data, for Table11069 filter only 11069 of the data, respectively, in the two tables to add Index

vyangliumsft_5-1725417523869.png

Home – Merge Queries -- Merge Queries as New

vyangliumsft_6-1725417539279.png

vyangliumsft_7-1725417539281.png

Select the columns to appear:

vyangliumsft_8-1725417558401.png

The data will be presented in a table

vyangliumsft_9-1725417558403.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Correct me if im wrong, and I probably explained this poorly, but this will not work since the code is setting the jobs manually. These columns need to change dynamically depending on what two jobs are selected from the slicer on the page. It will not always just be the two jobs I showed in the example. 

 

The two jobs in the pictures were just an example to explain what I need, but the user could pick two completely different jobs. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.