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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Baji_Komara
Frequent Visitor

IF condition for two different tables

Hi,

I have 2 tables conatining data of 6 months , I'm trying to apply the if condition for two different tables, Table A containig unique(not repeating) coustomer ID's and the Table B containing repeated coustomer id's that are repeating  only once in a month (refer the below screenshots for clarity). i want to create a new column in Table A by writing DAX IF code to get the purchase amount of the coustomer mapped to coustomer id in Table B. Table A and Table B mapped provided with relationship connecting claim numbers

Here is the DAX code i wanted to write to get the mapping

Method 1

Apri month= if('TableB'[financial_month] = April && 'TableA'[financial_month] = April , LOOKUPVALUE('TableB'[purchase_amount],'TableB'[coustomer_ID],'TableA'[coustomer_ID]))

 

May month = IF('TableB'[financial_month] = May && 'TableA'[financial_month] = May , LOOKUPVALUE('TableB'[purchase_amount],'TableB'[coustomer_ID],'TableA'[coustomer_ID]))

 

Method 2

April month = IF( Related (Table A [Financial_month]) = April ,LOOKUPVALUE('TableB'[purchase_amount],'TableB'[coustomer_ID],'TableA'[coustomer_ID]))

 

May month = if ( Related (Table A [Financial_month]) = May ,LOOKUPVALUE('TableB'[purchase_amount],'TableB'[coustomer_ID],'TableA'[coustomer_ID]))

 

 i want to write the above DAX codes for every month upto september

 

Since the coustomer ID's in Table B is repeating in every month i'm getting an error saying the data is repeated. when i tried to apply RELATED( ) in method2 after entering RELATED when i tried to enter the target column nothing is being suggested by PowerBI whatever i'm entering it is in lightgrey colour only and not changing to black

 

 

Please help me to resolve the issue and if possible suggest me a simpler way to get the data for every months without manually creating the columns

 

here claim_no = coustomer ID

Table A

Baji_Komara_3-1669115885249.png

Table B 

Baji_Komara_2-1669115859973.png 

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

Hi @Baji_Komara ,

 

You can try these methods:

 

Method1:

New columns like:

Apri month =
IF (
    MONTH ( 'TableA'[Financial Month] ) = 4,
    CALCULATE (
        SUM ( TableB[purchase_amount] ),
        FILTER (
            'TableB',
            MONTH ( 'TableB'[Financial Month] ) = 4
                && 'TableA'[CLAIM_NO] = 'TableB'[CLAIM_NO]
        )
    )
)

vyinliwmsft_0-1669169794465.png

 

Method2: Use matrix visual.

vyinliwmsft_1-1669169851026.png

Hope this helps you.

 

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

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

2 REPLIES 2
v-yinliw-msft
Community Support
Community Support

Hi @Baji_Komara ,

 

You can try these methods:

 

Method1:

New columns like:

Apri month =
IF (
    MONTH ( 'TableA'[Financial Month] ) = 4,
    CALCULATE (
        SUM ( TableB[purchase_amount] ),
        FILTER (
            'TableB',
            MONTH ( 'TableB'[Financial Month] ) = 4
                && 'TableA'[CLAIM_NO] = 'TableB'[CLAIM_NO]
        )
    )
)

vyinliwmsft_0-1669169794465.png

 

Method2: Use matrix visual.

vyinliwmsft_1-1669169851026.png

Hope this helps you.

 

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

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

 

 

hi @v-yinliw-msft ,

Thanks for your response and the solution 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors