<?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: Calculating values based on two tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151426#M112875</link>
    <description>&lt;P&gt;if you are adding calculated column in Products table, try this code&lt;/P&gt;
&lt;P&gt;NewColumn=COUNTROWS(RELATEDTABLE(Orders))*Products[Price]&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 02:38:10 GMT</pubDate>
    <dc:creator>wdx223_Daniel</dc:creator>
    <dc:date>2023-03-24T02:38:10Z</dc:date>
    <item>
      <title>Calculating values based on two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151093#M112861</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am a super beginner and have the following case:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have two tables: Products and Orders. They have a One-To-Many relationship so one Product might be in a few orders - a classic case. Product has a 'Price' column and an important note is that it's not a mandatory field - some products have the price and some products have it blank. I want to calculate a total value for each product based on the row count of related rows from the 'Orders' table. Formula like TotalValue = Product.Price * CountRows(Orders) where Orders.Product = Product&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;BR /&gt;Products:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Product&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Price&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Pencil&lt;/TD&gt;&lt;TD&gt;2.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Crayon&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Backpack&lt;/TD&gt;&lt;TD&gt;10,00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If in Orders we have two Pencils - we will get a total of 4.00, if we have 5 Backpacks - we get a total of 50, and Crayon is skipped.&lt;/P&gt;&lt;P&gt;These values will be displayed to the user as figures for each product having a price and also as a sum of all totals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I bet it's super easy but I'm also an absolute beginner in Power BI and DAX so I would be really thankful for any help!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 21:54:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151093#M112861</guid>
      <dc:creator>smartpug</dc:creator>
      <dc:date>2023-03-23T21:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating values based on two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151426#M112875</link>
      <description>&lt;P&gt;if you are adding calculated column in Products table, try this code&lt;/P&gt;
&lt;P&gt;NewColumn=COUNTROWS(RELATEDTABLE(Orders))*Products[Price]&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 02:38:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151426#M112875</guid>
      <dc:creator>wdx223_Daniel</dc:creator>
      <dc:date>2023-03-24T02:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating values based on two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151683#M112896</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Thanks for answering. Tried this and unfortunately, I get this error:&lt;BR /&gt;"A single value for column 'Price' in table 'Products' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is - when I was using aggregation for the 'Price' - e.g. Max('Price') - it was getting the highest 'Price' from the table and just multiplied it by all rows.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 06:23:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151683#M112896</guid>
      <dc:creator>smartpug</dc:creator>
      <dc:date>2023-03-24T06:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating values based on two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151691#M112897</link>
      <description>&lt;P&gt;maybe you want a measure, instead of calculated column&lt;/P&gt;
&lt;P&gt;NewMeasure=SUMX(Products,COUNTROWS(RELATEDTABLE(orders))*Products[Price])&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 06:37:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151691#M112897</guid>
      <dc:creator>wdx223_Daniel</dc:creator>
      <dc:date>2023-03-24T06:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating values based on two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151834#M112911</link>
      <description>&lt;P&gt;Yes, this is exactly what I need, thanks! Is it possible to modify this DAX to filter RELATEDTABLE(orders) to include only orders.DeliveryType = "Pickup"?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 07:49:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151834#M112911</guid>
      <dc:creator>smartpug</dc:creator>
      <dc:date>2023-03-24T07:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating values based on two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151847#M112913</link>
      <description>&lt;P&gt;&lt;SPAN&gt;NewMeasure=SUMX(Products,COUNTROWS(FILTER(RELATEDTABLE(orders),orders[DeliveryType]="Pickup"))*Products[Price])&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 07:53:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-values-based-on-two-tables/m-p/3151847#M112913</guid>
      <dc:creator>wdx223_Daniel</dc:creator>
      <dc:date>2023-03-24T07:53:50Z</dc:date>
    </item>
  </channel>
</rss>

