<?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 Create a DAX measure that calculates the percentage by gender of the Column total in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-DAX-measure-that-calculates-the-percentage-by-gender-of/m-p/3116691#M110388</link>
    <description>&lt;P&gt;Hello Community Members,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help with DAX.&lt;/P&gt;&lt;P&gt;Datasets showing last year's report. I need to create a DAX measure that calculates the percentage by gender of the Column total &lt;FONT color="#000000"&gt;(in Yellow marked value in the screenshot&lt;/FONT&gt;). Somehow, the mind got faded, not getting the correct solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created a DAX but giving error message (The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.).&lt;/P&gt;&lt;P&gt;Attached is the &lt;A title="Create a DAX measure that calculates the percentage by gender of the Column total" href="https://github.com/msncps/Power-BI-Community/blob/main/Test_v1.pbix" target="_self"&gt;PBIX file&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total % = 

VAR curmonth    =   month(max('TBL_L R'[Date]))
VAR curyear     =   year(max('TBL_L R'[Date]))
VAR gender      =   SELECTEDVALUE('TBL_L R'[Gender])
VAR Female      =   countx(filter('TBL_L',
                    year('TBL_L'[Date])=curyear 
                    &amp;amp;&amp;amp; month('TBL_L'[Date])=curmonth 
                    &amp;amp;&amp;amp; 'TBL_L'[Gender]=gender
                    &amp;amp;&amp;amp; 'TBL_L'[Gender] = "Female"
                    ),
                    TBL_L[Gender])
VAR Male      =   countx(filter('TBL_L',
                    year('TBL_L'[Date])=curyear 
                    &amp;amp;&amp;amp; month('TBL_L'[Date])=curmonth 
                    &amp;amp;&amp;amp; 'TBL_L'[Gender]=gender
                    &amp;amp;&amp;amp; 'TBL_L'[Gender] = "Male"
                    ),
                    TBL_L[Gender])
VAR Total      =
                    IF(SELECTEDVALUE ( 'TBL_L'[Gender] ) = "Female", 
                    DIVIDE(Female, Female+Male), ALLEXCEPT('TBL_L R','TBL_L R'[Gender])) &amp;amp;&amp;amp;
                    IF(SELECTEDVALUE ( 'TBL_L'[Gender] ) = "Male", 
                    DIVIDE(Male, Female+Male), ALLEXCEPT('TBL_L R','TBL_L R'[Gender]))

        RETURN 
                    Total&lt;/LI-CODE&gt;&lt;P&gt;Please help me to either tweak or create a new one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 14:49:23 GMT</pubDate>
    <dc:creator>PBIfolks</dc:creator>
    <dc:date>2023-03-07T14:49:23Z</dc:date>
    <item>
      <title>Create a DAX measure that calculates the percentage by gender of the Column total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-DAX-measure-that-calculates-the-percentage-by-gender-of/m-p/3116691#M110388</link>
      <description>&lt;P&gt;Hello Community Members,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help with DAX.&lt;/P&gt;&lt;P&gt;Datasets showing last year's report. I need to create a DAX measure that calculates the percentage by gender of the Column total &lt;FONT color="#000000"&gt;(in Yellow marked value in the screenshot&lt;/FONT&gt;). Somehow, the mind got faded, not getting the correct solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created a DAX but giving error message (The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.).&lt;/P&gt;&lt;P&gt;Attached is the &lt;A title="Create a DAX measure that calculates the percentage by gender of the Column total" href="https://github.com/msncps/Power-BI-Community/blob/main/Test_v1.pbix" target="_self"&gt;PBIX file&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total % = 

VAR curmonth    =   month(max('TBL_L R'[Date]))
VAR curyear     =   year(max('TBL_L R'[Date]))
VAR gender      =   SELECTEDVALUE('TBL_L R'[Gender])
VAR Female      =   countx(filter('TBL_L',
                    year('TBL_L'[Date])=curyear 
                    &amp;amp;&amp;amp; month('TBL_L'[Date])=curmonth 
                    &amp;amp;&amp;amp; 'TBL_L'[Gender]=gender
                    &amp;amp;&amp;amp; 'TBL_L'[Gender] = "Female"
                    ),
                    TBL_L[Gender])
VAR Male      =   countx(filter('TBL_L',
                    year('TBL_L'[Date])=curyear 
                    &amp;amp;&amp;amp; month('TBL_L'[Date])=curmonth 
                    &amp;amp;&amp;amp; 'TBL_L'[Gender]=gender
                    &amp;amp;&amp;amp; 'TBL_L'[Gender] = "Male"
                    ),
                    TBL_L[Gender])
VAR Total      =
                    IF(SELECTEDVALUE ( 'TBL_L'[Gender] ) = "Female", 
                    DIVIDE(Female, Female+Male), ALLEXCEPT('TBL_L R','TBL_L R'[Gender])) &amp;amp;&amp;amp;
                    IF(SELECTEDVALUE ( 'TBL_L'[Gender] ) = "Male", 
                    DIVIDE(Male, Female+Male), ALLEXCEPT('TBL_L R','TBL_L R'[Gender]))

        RETURN 
                    Total&lt;/LI-CODE&gt;&lt;P&gt;Please help me to either tweak or create a new one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 14:49:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-DAX-measure-that-calculates-the-percentage-by-gender-of/m-p/3116691#M110388</guid>
      <dc:creator>PBIfolks</dc:creator>
      <dc:date>2023-03-07T14:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create a DAX measure that calculates the percentage by gender of the Column total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-DAX-measure-that-calculates-the-percentage-by-gender-of/m-p/3116768#M110394</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="504904" data-lia-user-login="PBIfolks" class="lia-mention lia-mention-user"&gt;PBIfolks&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this can be simplified:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) create a simple measure to count the male/female column i.e. Count = count('TBL_L R'[Gender]); then&lt;/P&gt;&lt;P&gt;2) create another measure for the % i.e. % Measure = [Count]/calculate(count('TBL_L R'[Date]),allexcept('TBL_L R','TBL_L R'[Gender]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This ensures it is only creating the percentage by your column (gender) which is what it looks like you are trying to achieve.&lt;/P&gt;&lt;P&gt;It would be advisable to have a date dimension table joined to your fact table via the date field and use the date from this table as your row field in your matrix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 15:23:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-DAX-measure-that-calculates-the-percentage-by-gender-of/m-p/3116768#M110394</guid>
      <dc:creator>BITomS</dc:creator>
      <dc:date>2023-03-07T15:23:18Z</dc:date>
    </item>
  </channel>
</rss>

