<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating measure to give first result from related tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1134444#M16897</link>
    <description>&lt;P&gt;I don't see a date column, so I assume there is a single value only for any customer/category combination in your actual model.&amp;nbsp; If so, this should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make a matrix visual with Customer ID column on the rows, and Category column from the Product table.&amp;nbsp; Then put a measure like this in the values area - Rating = Min(Quarter[Customer rating])&lt;/P&gt;&lt;P&gt;Since you have a single value for each combo, this should work (Max would work same).&amp;nbsp; You could also just drag the rating column in the values area and choose 'First' aggregation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this works for you, please mark it as solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jun 2020 01:43:34 GMT</pubDate>
    <dc:creator>mahoneypat</dc:creator>
    <dc:date>2020-06-02T01:43:34Z</dc:date>
    <item>
      <title>Creating measure to give first result from related tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1089761#M15716</link>
      <description>&lt;P&gt;I have two tables&lt;/P&gt;&lt;P&gt;Quarter 1 table- A list of sales associated with a Customer ID. Each sale indicates the product purchased and gives a customer rating for that product.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Customer ID&lt;/TD&gt;&lt;TD&gt;Product Code&lt;/TD&gt;&lt;TD&gt;Customer rating&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0001&lt;/TD&gt;&lt;TD&gt;Bike # 7&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0002&lt;/TD&gt;&lt;TD&gt;Bell #1&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0003&lt;/TD&gt;&lt;TD&gt;Bike # 5&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Product table - A list of unique products and the category that they are associated with.&amp;nbsp; There are seven categories.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;Category&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bike # 7&lt;/TD&gt;&lt;TD&gt;Bike&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bike # 5&lt;/TD&gt;&lt;TD&gt;Bike&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bell #1&lt;/TD&gt;&lt;TD&gt;Bell&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two tables are related through a one to many relationship from Product to ProductCode.&lt;/P&gt;&lt;P&gt;I want to create a measure "Bike Category Rating" &amp;nbsp;that for each customer ID will return the first customer rating in the list based off of the product category "Bike" and will provide a blank response if there is no bike category rating&lt;/P&gt;&lt;P&gt;Eg&amp;nbsp; would look as below in a table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Customer ID&lt;/TD&gt;&lt;TD&gt;Bike category rating&lt;/TD&gt;&lt;TD&gt;Bell Category rating&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0001&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0002&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0003&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 13:07:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1089761#M15716</guid>
      <dc:creator>jessifi</dc:creator>
      <dc:date>2020-05-14T13:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating measure to give first result from related tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1089946#M15722</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="230767" data-lia-user-login="jessifi" class="lia-mention lia-mention-user"&gt;jessifi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could do this using EditQuery.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a blank query and copy-paste below query. Then go to steps one by one and understand it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product table&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKTylNLlHSUXJOLElNzy+qVIrViVZyysxOVVBWMAeKg5jIYqYoYqk5OQrKhiAhIEspNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Product", type text}, {"Category", type text}})
in
    #"Changed Type1"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Quarter 1 table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci4tLsnPTS1S8HRR0lEKKMpPKU0uUXDOT0kFcuGSRYklmXnpSrE60UoGBgaGQCmnzOxUBWUFcyDTESZuBBJPzclRUAargAkbI5SbQsRjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Merged Queries" = Table.NestedJoin(#"Promoted Headers", {"Product Code"}, #"Product table", {"Product"}, "Product table", JoinKind.LeftOuter),
    #"Expanded Product table" = Table.ExpandTableColumn(#"Merged Queries", "Product table", {"Category"}, {"Product table.Category"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Product table",{"Product Code"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Product table.Category"]), "Product table.Category", "Customer rating")
in
    #"Pivoted Column"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution!&lt;BR /&gt;Appreciate with a kudos &lt;/STRONG&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 15:02:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1089946#M15722</guid>
      <dc:creator>nandukrishnavs</dc:creator>
      <dc:date>2020-05-14T15:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating measure to give first result from related tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1134346#M16893</link>
      <description>&lt;P&gt;Hi nandukrishnavs,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I couldn't get your solution to work,&amp;nbsp; I think i'm just a little bit too inexperienced but I manged&amp;nbsp;to solve&amp;nbsp;my problem by using an IF statment to create a new column.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 23:53:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1134346#M16893</guid>
      <dc:creator>jessifi</dc:creator>
      <dc:date>2020-06-01T23:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating measure to give first result from related tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1134444#M16897</link>
      <description>&lt;P&gt;I don't see a date column, so I assume there is a single value only for any customer/category combination in your actual model.&amp;nbsp; If so, this should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make a matrix visual with Customer ID column on the rows, and Category column from the Product table.&amp;nbsp; Then put a measure like this in the values area - Rating = Min(Quarter[Customer rating])&lt;/P&gt;&lt;P&gt;Since you have a single value for each combo, this should work (Max would work same).&amp;nbsp; You could also just drag the rating column in the values area and choose 'First' aggregation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this works for you, please mark it as solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 01:43:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Creating-measure-to-give-first-result-from-related-tables/m-p/1134444#M16897</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-06-02T01:43:34Z</dc:date>
    </item>
  </channel>
</rss>

