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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Oros
Post Partisan
Post Partisan

Identify product based on another table

Hello,
 
I have 2 tables.  How do you identify which products are NOT counted?  How do you relate these 2 tables.   Thanks.
Oros_0-1712608605010.png

 

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Ensure that there is a Many to One relationship from the Count table to the Product table.  To your visual, drag Product from the Product table.  Write this measure

Count = coalesce(countrows(Count),0)

You may now filter the measure on 0.

Hope this helps.


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

Hi @Ashish_Mathur,

 

Thank yo for your reply.  I am getting a cardinality error for many to one relationship.  Any ideas?  Thanks again.

 

Oros_0-1712663291621.png

 

 

Ensure that there are no duplicates/blanks in the Products table.


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

hi @Oros ,

in power query, you could possibly do a full outer join. Filter the key columns on either table = blank and do a count.

 

create 3 blank queries and copy paste the code below into the advanced editor:

INPUTS: 

 

count 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcgwI8HFV0lHySsxTitWJVnJy9ANCoIBLajJYwD/I0c8dpMI/uQQs4B7qGAZS4JdfphQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, #"Date Counted" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Date Counted", type text}}),
    #"Uppercased Text" = Table.TransformColumns(#"Changed Type",{{"Product", Text.Upper, type text}}),
    #"Trimmed Text" = Table.TransformColumns(#"Uppercased Text",{{"Product", Text.Trim, type text}}),
    #"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"Product", Text.Clean, type text}})
in
    #"Cleaned Text"

 product

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcgwI8HFVitWJVnJy9ANCMNM/yNHPHSLqC2T5g1lBjsEBTq5BQZGhYG5wSJBjOJivFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}}),
    #"Uppercased Text" = Table.TransformColumns(#"Changed Type",{{"Product", Text.Upper, type text}}),
    #"Trimmed Text" = Table.TransformColumns(#"Uppercased Text",{{"Product", Text.Trim, type text}}),
    #"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"Product", Text.Clean, type text}})
in
    #"Cleaned Text"

 

output  (get the products in product table but not in the count table) : 

 

let
    Source = Table.NestedJoin(Table, {"Product"}, Count, {"Product"}, "Count", JoinKind.LeftOuter),
    #"Expanded Count" = Table.ExpandTableColumn(Source, "Count", {"Product", "Date Counted"}, {"Product.1", "Date Counted"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Count", each ([Product.1] = null)),
    #"Counted Rows" = Table.RowCount(#"Filtered Rows")
in
    #"Counted Rows"

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Hi @adudani ,

 

Thank you for your quick reply.  Should I replace the 'Product' with the actual product name table?

 

Oros_0-1712610582456.png

 

yes. 

or you could copy the steps after source if you'd like.

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.