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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GuestUser123
Regular Visitor

Comparison of First Index with the Second one

Hello Everyone,

I have a huge dataset with me wherein I have multiple Customer IDs and each ID has multiple entries associated with them. Some IDs have only 1 entry, hence they have only 1 Index and some have multiple entries thereby having multiple indexes (1,2,3, etc for each entry).

I want to consider only those IDs that have more than 1 index so that I could do a comparison between the 1st and 2nd row in order to check the value of a Payment field so as to know if there is any change in the Payment field value from Index 1 to Index 2. 

However, I am not able to implement this scenario. Below is the snapshot of the scenario.

Please help. 

Thank you.

 Example of the scenarioExample of the scenario

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @GuestUser123 ,

According to your description, here's my solution.

My sample data is the same with yours.

vkalyjmsft_0-1643967615665.png

Create a measure.

Check = 
IF (
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[CustomerID] = MAX ( 'Table'[CustomerID] )
                && 'Table'[Index] = 1
        ),
        'Table'[Payment]
    )
        = MAXX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[CustomerID] = MAX ( 'Table'[CustomerID] )
                    && 'Table'[Index] = 2
            ),
            'Table'[Payment]
        ),
    "Not change",
    "Change"
)

 Get the expected result.

vkalyjmsft_1-1643967659514.png

I attach my sample below for reference.

 

Best Regards,

 

Community Support Team _ kalyj

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

8 REPLIES 8
v-yanjiang-msft
Community Support
Community Support

Hi @GuestUser123 ,

According to your description, here's my solution.

My sample data is the same with yours.

vkalyjmsft_0-1643967615665.png

Create a measure.

Check = 
IF (
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[CustomerID] = MAX ( 'Table'[CustomerID] )
                && 'Table'[Index] = 1
        ),
        'Table'[Payment]
    )
        = MAXX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[CustomerID] = MAX ( 'Table'[CustomerID] )
                    && 'Table'[Index] = 2
            ),
            'Table'[Payment]
        ),
    "Not change",
    "Change"
)

 Get the expected result.

vkalyjmsft_1-1643967659514.png

I attach my sample below for reference.

 

Best Regards,

 

Community Support Team _ kalyj

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

GuestUser123
Regular Visitor

Hi @JirkaZ  Thanks for the reply. However, I have only one table with me having all the above fields and I have to compare the first row with the second one to see if there has been any change in the Payment method.

But you know you can abstract some other table from this one and do a proper modelling with many to one relationships etc., right?

Yes I can do that. However, could you please elaborate a bit more that even if I create another table from this one, do the data modelling as well.. But how will I pull only those rows where Index is more than 1 so that I could do a comparison on the Payment method for each Cust ID?

as I said before - then you can loop through the master customer table and evaluate the ROWCOUNT of the RELATEDTABLE to see if the customer has multiple indexes.

Hi @JirkaZ Is there a way to use an IF Condition in this scenario?

Yes, but you should first understand the concept and why you should normalize your model, what results would the countrows(relatedtable) give you and how to use it in your scenario. 

JirkaZ
Solution Specialist
Solution Specialist

It's really hard to tell what the outcome of you checks should be. I assume you have a master Customers table somewhere in your data model... so you could loop through the customers table and evaluate the row count of the related table (the one pictured) and then perform the operations you want.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors