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

Comparing values from two data sources

Hi All

Appreciate someone helping me out in this scenario.

I’ve two data sets that contains similar information. One of them is called “Gift Register” and the other is called “Expense Register”.

 

I want to do comparison between the two data to identify the match as well as mismatch. The rules I have are as follows:

If an entry is available in “Gift Register” but NOT available in “Expense Register”, then a column called “Expense Register Status” will be Red.

Example for this the entry for “James William” on 15/10/2020

 

If an entry is available in “Expense Register” but NOT available in “Gift Register”, then a column called “Gift Register Status” will be Red.

Example for this the entry for “Jessica Edward” on 6/6/2020

 

If the entry exists in both registers and the “Date” and “Gift Receiver” are matching, then I want to highlight the “value” in red.

 

I’m attaching sample data along with sample output as excel.

 

Gift Register

DateGift ReceiverGift ValueSponsoring Company
3/11/2020Jon Doe15Company A
5/5/2020James William30Company B
13/4/2020Steve Arin30Company A
15/10/2020James William10Company A

 

Expense Register

DateGift ReceiverGift ValueSponsoring Company
3/11/2020Jon Doe15Company A
5/5/2020James William20Company B
13/4/2020Steve Arin30Company A
6/6/2020Jessica Edward25Company B

 

Desired Output

DateGift ReceiverGift Register ValueExpense Register ValueGift Register StatusExpense Register Status
3/11/2020Jon Doe1515 GREEN GREEN
5/5/2020James William2030 GREEN GREEN
13/4/2020Steve Arin3030 GREEN GREEN
15/10/2020James William1010 GREEN RED
6/6/2020Jessica Edward2525 RED GREEN

 

 

 

YJAMOUS_0-1605544897049.png

 

 

5 REPLIES 5
Anonymous
Not applicable

Thanks a lot @v-stephen-msft 

Is there a way that I can show in the table BOTH Gift Receiver from both tables?

So I will have column for "Gift Register Receiver" and "Expense Register Receiver"

The rest will be the same. 

Thanks a lot

DateGift Register ReceiverExpense Register ReceiverGift Register ValueExpense Register ValueGift Register ValueExpense Register Value
       
       

Hi @Anonymous ,

 

For new questions, please reopen the post to ask, thank you.

 

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

 

Best Regards,

Stephen Tao

v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

The final effect is shown in the figure below, and I will explain the steps below.

19.png

 

1.Create a column in the Expense Register table.

 

Column = IF(NOT([Date] in VALUES('Gift Register'[Date])),1)

 

 

2.Create a column in the Gift Register table.

 

Column = IF(NOT([Date] in VALUES('Expense Register'[Date])),1)

 

 

3.Create a table by DAX.

 

Table = 
VAR tt =
    SELECTCOLUMNS (
        'Expense Register',
        "Expense Date", [Date],
        "Expense Gift Receiver", [Gift Receiver],
        "Expense Gift Value", [Gift Value]
    )
VAR tt2 =
    SELECTCOLUMNS (
        'Gift Register',
        "Gift Date", [Date],
        "Gift Gift Receiver", [Gift Receiver],
        "Gift Gift Value", [Gift Value]
    )
VAR tt3 =
    FILTER (
        CROSSJOIN ( tt, tt2 ),
        [Gift Date] = [Expense Date]
            && [Expense Gift Receiver] = [Gift Gift Receiver]
    )
VAR tt4 =
    SELECTCOLUMNS (
        tt3,
        "Date", [Expense Date],
        "Gift Receiver", [Expense Gift Receiver],
        "Gift Register Value", [Gift Gift Value],
        "Expense Register Value", [Expense Gift Value],
        "Gift Register Status", "Green",
        "Expense Register Status", "Green"
    )
VAR tt5 =
    FILTER (
        SELECTCOLUMNS (
            'Expense Register',
            "Date", IF ( [Column] = 1, [Date] ),
            "Gift Receiver", IF ( [Column] = 1, [Gift Receiver] ),
            "Gift Value", IF ( [Column] = 1, [Gift Value] )
        ),
        NOT ( ISBLANK ( [Date] ) )
    )
VAR tt6 =
    SELECTCOLUMNS (
        tt5,
        "Date", [Date],
        "Gift Receiver", [Gift Receiver],
        "Gift Register Value", [Gift Value],
        "Expense Register Value", [Gift Value],
        "Gift Register Status", "Red",
        "Expense Register Status", "Green"
    )
VAR tt7 =
    FILTER (
        SELECTCOLUMNS (
            'Gift Register',
            "Date", IF ( [Column] = 1, [Date] ),
            "Gift Receiver", IF ( [Column] = 1, [Gift Receiver] ),
            "Gift Value", IF ( [Column] = 1, [Gift Value] )
        ),
        NOT ( ISBLANK ( [Date] ) )
    )
VAR tt8 =
    SELECTCOLUMNS (
        tt7,
        "Date", [Date],
        "Gift Receiver", [Gift Receiver],
        "Gift Register Value", [Gift Value],
        "Expense Register Value", [Gift Value],
        "Gift Register Status", "Green",
        "Expense Register Status", "Red"
    )
RETURN
    UNION ( tt4, tt6, tt8 )

 

 

4.Create a measure.

 

Measure = IF(MAX('Table'[Gift Register Value])=MAX('Table'[Expense Register Value]),"Green","Red")

 

 

5.Use Conditional formatting under Format to set the colors.

18.png

 

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

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

lbendlin
Super User
Super User

Have you considered using the EXCEPT() and INTERSECT() DAX functions?

Anonymous
Not applicable

I'm not sure if this will work since EXCEPT() and INTERSECT() matches one column. I want to make sure several columns match.

For example: I need to check both date and Gift Receiver to confirm if there's match or not and compare. So, is my assumption right regarding the EXCEPT and INTERSECT?

 

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.