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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Oros
Post Prodigy
Post Prodigy

Cannot relate tables

Hello,

 

I have a main sales table that has dollar sold@cost and dollar sold@retail. 

 

Oros_0-1704042041956.png

I have a second table with QTY sold and  a third table with QTY credited.

 

I would like to add a QTY column to my main sales table but it seems like there is an issue with the table relationships.

 

Here is the sample pbix file.

 

https://file.io/GVhIlZM4PyGS 

 

Any help is highly appreciated.  Thanks!

 

 

 

 

2 ACCEPTED SOLUTIONS

Hi,

In the attached PBI file, create a single column table of all unique products from Dollar and Qty tables.  Create a Many to One relationship from Dollar and Qty tables to this new product table.  To your visual, drag Product from the new table.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Anonymous
Not applicable

Hi @Oros ,

I updated your sample pbix file(see the attachment), please find the details in it.

1. Delete the relationship between tables

2. Create a calculated column as below

Column = 
VAR _invoiceqty =
    CALCULATE (
        SUM ( 'INVOICE QTY'[QTY INVOICED] ),
        FILTER ( 'INVOICE QTY', 'INVOICE QTY'[PRODUCT] = 'SALES TABLE'[PRODUCT] )
    )
VAR _maxpdate =
    CALCULATE (
        MAX ( 'CREDIT QTY'[POSTING DATE] ),
        FILTER ( 'CREDIT QTY', 'CREDIT QTY'[PRODUCT] = 'SALES TABLE'[PRODUCT] )
    )
VAR _creditqty =
    CALCULATE (
        SUM ( 'CREDIT QTY'[QTY CREDITED] ),
        FILTER ( 'CREDIT QTY', 'CREDIT QTY'[PRODUCT] = 'SALES TABLE'[PRODUCT] )
    )
RETURN
    IF (
        ISBLANK ( _creditqty ),
        BLANK (),
        IF ( 'SALES TABLE'[POSTING DATE] = _maxpdate, _invoiceqty + _creditqty )
    )

vyiruanmsft_0-1704091885530.png

Best Regards

View solution in original post

13 REPLIES 13
Anonymous
Not applicable

Hi @Oros ,

I updated your sample pbix file(see the attachment), please find the details in it.

1. Delete the relationship between tables

2. Create a calculated column as below

Column = 
VAR _invoiceqty =
    CALCULATE (
        SUM ( 'INVOICE QTY'[QTY INVOICED] ),
        FILTER ( 'INVOICE QTY', 'INVOICE QTY'[PRODUCT] = 'SALES TABLE'[PRODUCT] )
    )
VAR _maxpdate =
    CALCULATE (
        MAX ( 'CREDIT QTY'[POSTING DATE] ),
        FILTER ( 'CREDIT QTY', 'CREDIT QTY'[PRODUCT] = 'SALES TABLE'[PRODUCT] )
    )
VAR _creditqty =
    CALCULATE (
        SUM ( 'CREDIT QTY'[QTY CREDITED] ),
        FILTER ( 'CREDIT QTY', 'CREDIT QTY'[PRODUCT] = 'SALES TABLE'[PRODUCT] )
    )
RETURN
    IF (
        ISBLANK ( _creditqty ),
        BLANK (),
        IF ( 'SALES TABLE'[POSTING DATE] = _maxpdate, _invoiceqty + _creditqty )
    )

vyiruanmsft_0-1704091885530.png

Best Regards

Hi @Anonymous ,

 

This works as well,  Thanks!

Ashish_Mathur
Super User
Super User

Hi,

There is no file there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur ,

 

Sorry again.  Here it is:

sample file

Hi @Ashish_Mathur ,

 

Sorry, here is the file.

sample.pbix

 

and here is what I would like to achieve.  Thanks!

Oros_0-1704068229164.png

 

 

No file there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

In the attached PBI file, create a single column table of all unique products from Dollar and Qty tables.  Create a Many to One relationship from Dollar and Qty tables to this new product table.  To your visual, drag Product from the new table.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur ,

 

Thank you so much!!! Works like a charm!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

There is still no file there.  Recheck before you post.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
PijushRoy
Super User
Super User

Hi @Oros 

Please check the relationship

PijushRoy_0-1704046899284.png

https://drive.google.com/file/d/1MCKGaxaw_ZWA_uwrZwNr0PtrcQBYaKo1/view?usp=sharing

 

If solved your requirement, please mark this answer as SOLUTION.
If this comment helps you, appreciate your KUDOS


Pijush




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





HI @PijushRoy ,

 

Thank you for your quick reply.  Maybe I am missing something.

 

I cannot find in your sample solution the correct QTY column.  I would like to add the QTY column here, where the QTY is the total of QTY Sales and QTY Credits for each product.  If Apple has a total QTY sale of 10 but a return (credit) of 5, then Apple should have a total QTY column of 5.

Oros_1-1704055170749.png

Thanks again.

 

 

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.