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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Neve12ende12
Frequent Visitor

Find the Absence of Relationships

Simple goal. Give me a list of account numbers that do not have an auto loan. An account can have many loans and a loan can belong to a single account. Here is the SQL I wrote to generate the list, but how could I do this in PowerBI?

 

 

SELECT account.ACCOUNTNUMBER, COUNT(loan.PARENTACCOUNT) AS 'AUTO_LOAN_COUNT'
FROM dbo.Lite_Accounts account
LEFT JOIN dbo.Lite_Loans loan ON loan.PARENTACCOUNT = account.ACCOUNTNUMBER AND loan.CLOSE_DATE AND loan.[TYPE] IN ('USED VEHICLE', 'NEW VEHICLE')
WHERE account.CLOSE_DATE IS NULL
GROUP BY account.ACCOUNTNUMBER
HAVING COUNT(loan.PARENTACCOUNT) = 0

 

 




1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Neve12ende12 there are few ways to do this, add a measure and then use it for visual level filter or add a new column in account table and then filter on this column

 

Measure:

 

Measure Filter = IF ( CALCULATE ( COUNTROWS ( LoanTable ), LoanTable[Type] IN { "Old", "New" } ) == BLANK(), 1, 0 )

 

Use this measure as visual level filter where measure value is 1

 

Column

 

Loan Taken = CALCULATE ( COUNTROWS( LoanTable ), LoanTable[Type] IN { "Old", "New" } )

 

It will create count of loans in account table, and one which doesn't have loans, it will be blank, now you can filter on this column by saying where this column value is BLANK

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

1 REPLY 1
parry2k
Super User
Super User

@Neve12ende12 there are few ways to do this, add a measure and then use it for visual level filter or add a new column in account table and then filter on this column

 

Measure:

 

Measure Filter = IF ( CALCULATE ( COUNTROWS ( LoanTable ), LoanTable[Type] IN { "Old", "New" } ) == BLANK(), 1, 0 )

 

Use this measure as visual level filter where measure value is 1

 

Column

 

Loan Taken = CALCULATE ( COUNTROWS( LoanTable ), LoanTable[Type] IN { "Old", "New" } )

 

It will create count of loans in account table, and one which doesn't have loans, it will be blank, now you can filter on this column by saying where this column value is BLANK

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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