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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
as65fgdax
Frequent Visitor

How to include a column from a related table in visual?

I am still figuring out Power BI. I have got seemingly a very simple task: make a visual table in report view include a column from another table.

I have got:
GL - a table with invoice information, including client ID

NC - a table with credit note information, including client ID

Clients - a table with client ID as a unique identifier

Tables are not merged, but I made relationships in model view via Clients table. In the report view, I have made a table based on GL, which shows distinct count of invoices per client. I have also included a calculated column showing a ratio of credit notes to invoices like this:

Ratio NC/INV =
 VAR ClientNumber = 'GL'[ClientID]
 VAR TotalInvoices =
        CALCULATE(
            DISTINCTCOUNT('GL'[Invoice number]),
            FILTER('GL', 'GL'[ClientID]=ClientNumber)
        )
 VAR TotalNC =
        CALCULATE(
            DISTINCTCOUNT('NC'[NC number]),
            FILTER('NC', 'NC'[ClientID]=ClientNumber)
        )
  RETURN IF(OR(TotalNC=0, TotalInvoices=0), 0, DIVIDE(TotalNC, TotalInvoices))
 
What I am not able to do is include a column in the same visual, showing distinct count of credit notes from NC. I tried as a calculated column and as a measure:
TotalNC = CALCULATE( DISTINCTCOUNT('NC'[NC number]), ALLEXCEPT('NC', 'NC'[Client ID]) ) 

Neither worked. Instead of giving a distinct count per line (per client), it gives me the total count of NC in every line. The only way it works correctly if I make a direct many-to-many relationship between NC and GL. But obviously then other things break down in my report 🙂 

Please help!




3 REPLIES 3
as65fgdax
Frequent Visitor

I tried this as a measure, as a column in GL and in NC, after I reference it in the visual with GL columns, I only get the grand total in every row 😕

Mahesh0016
Super User
Super User

@as65fgdax Please Try below Dax :

TotalNC =
CALCULATE (
COUNROWS(VALUES( 'NC'[NC number] ) ),
ALLEXCEPT ( 'NC', 'NC'[Client ID] )
)

> if its work please share your EndOutPut in table.

 

@as65fgdax Thank You!!

I ended up appending the two tables because the previous approach didn't seem to work.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.