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

Create Measure between Multiple tables

I want to create a measure to get the below result

 

Measure =  If Data Source (Serial No) & Amount Matches [tables] Table 1 (Serial No) & Amount or Table 2  (Serial No) & Amount or Table 3 (Serial No) & Amount or Table 4 (Serial No) & Amount return “ok” else “Error”

 

Then calculate the Amount difference and show in the last column

 

Result Display

SERIAL NOAMOUNTSTATUSAMOUNT DIFFERENCE
90909395601985OK0
90909395611985OK0
90909395621985OK0
90909395631985OK0
90909395644755OK0
90909395651170Error170
90909395661085OK0
90909395671855Error5
90909395702595OK0

 

Please find below the sample if this helps.

 

Click here PBIX

 

Thanks

Gaurav

2 ACCEPTED SOLUTIONS

@gaurav-narchal ,

One of the ways is to use these measures (I assume your tables are connected via Serial No column):

 

#check = 
VAR _t = UNION('Table 1','Table 2','Table 3','Table 4')
VAR amt = SUMX(_t, [AMOUNT])
VAR dsAmt = SUM('Data Source'[AMOUNT])
RETURN
IF(dsAmt = amt, "OK", "Error")
#diff = 
VAR _t = UNION('Table 1','Table 2','Table 3','Table 4')
VAR amt = SUMX(_t, [AMOUNT])
VAR dsAmt = SUM('Data Source'[AMOUNT])
RETURN
IF([#check] = "Error", amt - dsAmt, 0)

 

ERD_0-1622179272954.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

@gaurav-narchal ,

Please, check data types of the SN column in all tables. It should be whole number.

Here I used another table without one of the values to make sure it works:

ERD_0-1622210229083.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

9 REPLIES 9
ERD
Super User
Super User

Hi @gaurav-narchal ,

Do I understand correctly that Serial No from Data Source table can be met only at one of the tables?

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Hi @ERD - Yes Serial number from Data Source table can be met only at one of the tables. 

 

Thank You.

@gaurav-narchal ,

One of the ways is to use these measures (I assume your tables are connected via Serial No column):

 

#check = 
VAR _t = UNION('Table 1','Table 2','Table 3','Table 4')
VAR amt = SUMX(_t, [AMOUNT])
VAR dsAmt = SUM('Data Source'[AMOUNT])
RETURN
IF(dsAmt = amt, "OK", "Error")
#diff = 
VAR _t = UNION('Table 1','Table 2','Table 3','Table 4')
VAR amt = SUMX(_t, [AMOUNT])
VAR dsAmt = SUM('Data Source'[AMOUNT])
RETURN
IF([#check] = "Error", amt - dsAmt, 0)

 

ERD_0-1622179272954.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Hi @ERD 

 

I'm almost there. I also need to validate if the serial number does exist in the Data Source table and Table 1 , 2 , 3 and 4. How can i validate this through measure?


Measure =  If Data Source (Serial No) Matches [tables] Table 1 ,2 3 & 4 (Serial No) return “ok” else “Error”

 

#check =
VAR _t = UNION('Table 1','Table 2','Table 3','Table 4')
VAR amt = SUMX(_t, [AMOUNT])
VAR dsAmt = SUM('Data Source'[AMOUNT])
RETURN
IF(dsAmt = amt, "OK", "Error")

 

 Thanks

@gaurav-narchal ,

You can use this measure:

#checkIfExists = 
VAR currentSN = SELECTEDVALUE('Data Source'[SERIAL NO])
VAR _t = 
UNION (
        DISTINCT ( 'Table 1'[SERIAL NO] ),
        DISTINCT ( 'Table 2'[SERIAL NO] ),
        DISTINCT ( 'Table 3'[SERIAL NO] ),
        DISTINCT ( 'Table 4'[SERIAL NO] )
    )
RETURN
IF(currentSN IN _t, "OK", "Error")

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Hi @ERD 

 

This measure is not working. 

 

gaurav-narchal_0-1622208127521.png

gaurav-narchal_1-1622208274172.png

 

@gaurav-narchal ,

Please, check data types of the SN column in all tables. It should be whole number.

Here I used another table without one of the values to make sure it works:

ERD_0-1622210229083.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Hi @ERD - Some of the serial numbers are only aplhabets (JKHTGBLR) or blank how can i ignore them through the same measure.

 

Thank you for all your help.

@gaurav-narchal ,

It doesn't metter which type - Whole number or Text. The idea is that all the SN columns are of the SAME type.

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

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.