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
Anonymous
Not applicable

How to do a compare based on two columns

Thanks for helping!  We have two columns of data- column 1 is a date, column 2 is a text field with a pending action .  This along with a primary key of project number.  We want to be able to choose dates, and have a visual list those dates that have the same pending actions.  For example-

ProjectSource File DatePending_Activity
TD10058551/1/202308-All Requirements Met Not Completed
TD100585510/29/202308-All Requirements Met Not Completed
TD100585511/5/202308-All Requirements Met Not Completed
TD100585511/12/202308-All Requirements Met Not Completed
TD100585511/26/202308-All Requirements Met Not Completed
TD10135401/1/202301-Cancelled/Pending Cancellation
TD101354010/29/202302-Closed
TD101354011/5/202302-Closed
TD101354011/12/202302-Closed
TD101354011/26/202302-Closed
TD10189011/1/202313-PreConstruction Not Completed
TD101890110/29/202311-ATP for Construction Not Completed
TD101890111/5/202310-WO Sent to RPPM Not Completed
TD101890111/12/202315-Electrical Construction Not Started
TD101890111/26/202317-Electrical Construction Not Completed

 

We want to be able to create a list of projects where the pending activity for the latest week- 11/26/2023- matches the pending activity on 1/1/2023.  In the sample above, only TD1005855 would show in the visual.  We have about 30,000 projects, and want a visual that would illustrate.  We MAY also want to compare week to week, but for now lookingonly to compare current week to 1/1/2023.  Any thoughts are appreciated.

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @Anonymous 

 

If you don’t have a Project dimension table:
In Power Query, create a new query by referencing your table. Remove all columns except [Project]. Remove duplicates. Close Power Query.


Create a 1:* relationship between ‘Project’[Project] and ‘Table’[Project] (single)

 

3 measures:

 

_FirstStatus = 
    IF(
        ISINSCOPE( 'Project'[Project] ),
        CALCULATE(
            MAX( 'StatusTable'[Pending_Activity] ),
            'StatusTable'[Source File Date] = DATE( 2023, 1, 1 )
        )
    )

_LatestStatus = 
 VAR _MaxDt =
    MAXX(
        ALL( 'StatusTable' ),
        [Source File Date]
    )
RETURN
    IF(
        ISINSCOPE( 'Project'[Project] ),
        CALCULATE(
            MAX( 'StatusTable'[Pending_Activity] ),
            'StatusTable'[Source File Date] = _MaxDt
        )
    )

Compare = 
    COUNTROWS(
        FILTER(
            VALUES( 'Project'[Project] ),
            [_FirstStatus] = [_LatestStatus]
        )
    )

 

 

Let me know if you have questions.

 

Compare latest status to first status.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

2 REPLIES 2
gmsamborn
Super User
Super User

Hi @Anonymous 

 

If you don’t have a Project dimension table:
In Power Query, create a new query by referencing your table. Remove all columns except [Project]. Remove duplicates. Close Power Query.


Create a 1:* relationship between ‘Project’[Project] and ‘Table’[Project] (single)

 

3 measures:

 

_FirstStatus = 
    IF(
        ISINSCOPE( 'Project'[Project] ),
        CALCULATE(
            MAX( 'StatusTable'[Pending_Activity] ),
            'StatusTable'[Source File Date] = DATE( 2023, 1, 1 )
        )
    )

_LatestStatus = 
 VAR _MaxDt =
    MAXX(
        ALL( 'StatusTable' ),
        [Source File Date]
    )
RETURN
    IF(
        ISINSCOPE( 'Project'[Project] ),
        CALCULATE(
            MAX( 'StatusTable'[Pending_Activity] ),
            'StatusTable'[Source File Date] = _MaxDt
        )
    )

Compare = 
    COUNTROWS(
        FILTER(
            VALUES( 'Project'[Project] ),
            [_FirstStatus] = [_LatestStatus]
        )
    )

 

 

Let me know if you have questions.

 

Compare latest status to first status.pbix

 



Proud to be a Super User!

daxformatter.com makes life EASIER!
Anonymous
Not applicable

Looks simple and GREAT, will try tonight and give thumbs up tomorrow, THANKS for the help!

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.