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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
tewtom
Regular Visitor

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 @tewtom 

 

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

 

View solution in original post

2 REPLIES 2
gmsamborn
Super User
Super User

Hi @tewtom 

 

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

 

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.