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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dark_z
Regular Visitor

How to compare data in multiple rows in a table

Hi

 

I have a dataset similar to the table below, the table contains two activities with one row per step that generate progress/percent complete. I would like to get a column with a "1" or bool true in to indicate what row has the newest ActualDate per activity, and one column with a "1" or bool true to indicate what is the next step within the activity (row with oldest planned date without actual date)

 

ActivityIDActivityNameActualDatePlannedDatePercentComplete
A1000Activity 110.07.201710.07.201725
A1000Activity 116.09.201710.09.201750
A1000Activity 1 02.10.201760
A1000Activity 1 28.10.201775
A1000Activity 1 03.11.2017100
A2000Activity 203.10.201702.10.201710
A2000Activity 205.10.201706.10.201720
A2000Activity 212.10.201712.10.201750
A2000Activity 2 15.10.201760
A2000Activity 2 20.10.201770
A2000Activity 2 28.10.2017100

 

 

The result should be something like this :

 

ActivityIDActivityNameActualDatePlannedDatePercentCompleteLastActualNextPlanned
A1000Activity 110.07.201710.07.201725  
A1000Activity 116.09.201710.09.2017501 
A1000Activity 1 02.10.201760 1
A1000Activity 1 28.10.201775  
A1000Activity 1 03.11.2017100  
A2000Activity 203.10.201702.10.201710  
A2000Activity 205.10.201706.10.201720  
A2000Activity 212.10.201712.10.2017501 
A2000Activity 2 15.10.201760 1
A2000Activity 2 20.10.201770  
A2000Activity 2 28.10.2017100  

 

 

Can anyone help me out with regards to where I should start?

1 ACCEPTED SOLUTION

HI @dark_z

 

This is the revised Formula

LastActual=
VAR MyMax =
    MAXX (
        FILTER (
            Table1,
            Table1[ActivityName] = EARLIER ( Table1[ActivityName] )
                && NOT ( ISBLANK ( Table1[ActualDate] ) )
        ),
        Table1[PercentComplete]
    )
RETURN
    IF (
        Table1[ActualDate]
            = MAXX (
                FILTER ( Table1, Table1[ActivityName] = EARLIER ( Table1[ActivityName] ) ),
                Table1[ActualDate]
            )
            && Table1[PercentComplete] = MyMax,
        1
    )

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

Hi @dark_z

 

Add this calculated column for Lastactual

 

LastActual =
IF (
    Table1[ActualDate]
        = MAXX (
            FILTER ( Table1, Table1[ActivityName] = EARLIER ( Table1[ActivityName] ) ),
            Table1[ActualDate]
        ),
    1
)

Regards
Zubair

Please try my custom visuals

Thanks a lot. Actually, that solved my initial problem!

 

However, when i look closer at the data, i found an issue using what I was trying to do as some of the activities has the same actual date on several rows and I need only the row with the highest Percent Complete. I have updated the table below to show how the result became. For "Activity 1" i only want a "1" in LastActual on the row with 50% complete, not the one with 25% complete. Are you able to help me out with that as well?

 

ActivityIDActivityNameActualDatePlannedDatePercentCompleteLastActualNextPlanned
A1000Activity 116.09.201710.07.2017251 
A1000Activity 116.09.201710.09.2017501 
A1000Activity 1 02.10.201760 1
A1000Activity 1 28.10.201775  
A1000Activity 1 03.11.2017100  
A2000Activity 203.10.201702.10.201710  
A2000Activity 212.10.201706.10.2017201 
A2000Activity 212.10.201712.10.2017501 
A2000Activity 2 15.10.201760 1
A2000Activity 2 20.10.201770  
A2000Activity 2 28.10.2017100  

HI @dark_z

 

This is the revised Formula

LastActual=
VAR MyMax =
    MAXX (
        FILTER (
            Table1,
            Table1[ActivityName] = EARLIER ( Table1[ActivityName] )
                && NOT ( ISBLANK ( Table1[ActualDate] ) )
        ),
        Table1[PercentComplete]
    )
RETURN
    IF (
        Table1[ActualDate]
            = MAXX (
                FILTER ( Table1, Table1[ActivityName] = EARLIER ( Table1[ActivityName] ) ),
                Table1[ActualDate]
            )
            && Table1[PercentComplete] = MyMax,
        1
    )

Regards
Zubair

Please try my custom visuals

Hi @dark_z

Following calculated column for Next Planned

 

NextPlanned =
IF (
    Table1[PlannedDate]
        = MINX (
            FILTER (
                Table1,
                Table1[ActivityName] = EARLIER ( Table1[ActivityName] )
                    && ISBLANK ( Table1[ActualDate] )
            ),
            Table1[PlannedDate]
        ),
    1
)

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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