Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

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.

  • 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

     

2 Replies

  • 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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

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