<?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: dax, value if measure on other table on same level data,store &amp;gt; 0 in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3125471#M111007</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355709" data-lia-user-login="AntonL" class="lia-mention lia-mention-user"&gt;AntonL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;# staffing 2 :=&lt;BR /&gt;SUMX (&lt;BR /&gt;CROSSJOIN ( VALUES ( dim_Date[DateID] ), VALUES ( dim_Stores[StoreID] ) ),&lt;BR /&gt;VAR max_date = dim_Date[DateID]&lt;BR /&gt;VAR max_store = dim_Stores[StoreID]&lt;BR /&gt;VAR employees_count = [# employees]&lt;BR /&gt;VAR stf_calc =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM ( fact_Staffing_schedule_scd[staffing_count] ),&lt;BR /&gt;fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,&lt;BR /&gt;fact_Staffing_schedule_scd[date_to] &amp;gt; max_date&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF ( employees_count &amp;gt; 0, stf_calc, filter_table )&lt;BR /&gt;)&lt;/P&gt;</description>
    <pubDate>Sat, 11 Mar 2023 13:47:32 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2023-03-11T13:47:32Z</dc:date>
    <item>
      <title>dax, value if measure on other table on same level data,store &gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3124953#M110961</link>
      <description>&lt;P&gt;hi all&lt;/P&gt;&lt;P&gt;need help&lt;/P&gt;&lt;P&gt;have a table with employees movement documents(hired, dismissed)&lt;/P&gt;&lt;P&gt;with DateID, StoreID columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# hired:=
CALCULATE(sum(fact_Movement[action_value]),FILTER(fact_Movement,[action_type_code]=1))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then running total on date level&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# hired rt:=

VAR MaxDate = MAX (dim_Date[DateID]) -- Saves the last visible date

RETURN
CALCULATE ([# hired],dim_Date[DateID] &amp;lt;= MaxDate,ALL(dim_Date))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the same for dissmissed as for hired(but for dissmissed documents [action_type_code]=2)&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# dissmissed := ....same schema as hired

# dissmissed rt: = ....same schema as hired&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- its number of employes on any date&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# employees:= calculate ([# hired rt]+[# dismissed rt])&lt;/LI-CODE&gt;&lt;P&gt;so i have&amp;nbsp; as result date, store,&amp;nbsp;# employees&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;next:&lt;/P&gt;&lt;P&gt;also ihave&amp;nbsp; SCD table for staffing count( table show that for this store in period from .... to .... planned count of employees = xx)&lt;/P&gt;&lt;P&gt;StoreID, date_from, date_to, staff_count&lt;/P&gt;&lt;P&gt;with this formula i'm calculating number of planned staff on any date level&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# staffing:=

VAR max_date = MAX (dim_Date[DateID]) -- Saves the last visible date

return
CALCULATE ( sum(fact_Staffing_schedule_scd[staffing_count]),
fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;question:&lt;/P&gt;&lt;P&gt;i need to calculate [# staffing]&lt;/P&gt;&lt;P&gt;only if [# employees] on same DateID, StoreID &amp;gt; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;help please)&lt;/P&gt;&lt;P&gt;i wrote this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# staffing 2:=
VAR max_date = MAX(dim_Date[DateID])
VAR max_store = MAX(dim_Stores[StoreID])
VAR employees_count = [# employees]

VAR stf_calc =
CALCULATE ( sum(fact_Staffing_schedule_scd[staffing_count]),
fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
)


VAR filter_table =
CALCULATETABLE(
VALUES(fact_Staffing_schedule_scd[store_id]),
fact_Staffing_schedule_scd[store_id] = max_store,
fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
)
RETURN
IF(employees_count &amp;gt; 0,
CALCULATE(stf_calc, filter_table),
BLANK()
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so on date or store level it show OK&lt;/P&gt;&lt;P&gt;but on total, or subtotal level - it shows full value with excluded stores&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 20:01:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3124953#M110961</guid>
      <dc:creator>AntonL</dc:creator>
      <dc:date>2023-03-10T20:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: dax, value if measure on other table on same level data,store &gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3125471#M111007</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355709" data-lia-user-login="AntonL" class="lia-mention lia-mention-user"&gt;AntonL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;# staffing 2 :=&lt;BR /&gt;SUMX (&lt;BR /&gt;CROSSJOIN ( VALUES ( dim_Date[DateID] ), VALUES ( dim_Stores[StoreID] ) ),&lt;BR /&gt;VAR max_date = dim_Date[DateID]&lt;BR /&gt;VAR max_store = dim_Stores[StoreID]&lt;BR /&gt;VAR employees_count = [# employees]&lt;BR /&gt;VAR stf_calc =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM ( fact_Staffing_schedule_scd[staffing_count] ),&lt;BR /&gt;fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,&lt;BR /&gt;fact_Staffing_schedule_scd[date_to] &amp;gt; max_date&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF ( employees_count &amp;gt; 0, stf_calc, filter_table )&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 13:47:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3125471#M111007</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-11T13:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: dax, value if measure on other table on same level data,store &gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3125619#M111014</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp; for your reply&lt;/P&gt;&lt;P&gt;i also added to your query&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;VAR filter_table =
CALCULATETABLE(
VALUES(fact_Staffing_schedule_scd[store_id]),
fact_Staffing_schedule_scd[store_id] = max_store,
fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;full code of measure is:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# staffing 2:=


SUMX (
CROSSJOIN ( VALUES ( dim_Date[DateID] ), VALUES ( dim_Stores[StoreID] ) ),
VAR max_date = dim_Date[DateID]
VAR max_store = dim_Stores[StoreID]
VAR employees_count = [# employees]
VAR stf_calc =
CALCULATE (
SUM ( fact_Staffing_schedule_scd[staffing_count] ),
fact_Staffing_schedule_scd[store_id] = max_store,
fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
)


VAR filter_table =
CALCULATETABLE(
VALUES(fact_Staffing_schedule_scd[store_id]),
fact_Staffing_schedule_scd[store_id] = max_store,
fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
)

RETURN
IF ( employees_count &amp;gt; 0, stf_calc, filter_table )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but its calculate some very big numbers...(not real)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 18:30:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3125619#M111014</guid>
      <dc:creator>AntonL</dc:creator>
      <dc:date>2023-03-11T18:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: dax, value if measure on other table on same level data,store &gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3126355#M111053</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;BR /&gt;I can understand from some of your amendments that dimStores and&amp;nbsp;&lt;SPAN&gt;fact_Staffing_schedule_scd are not related therefore there is a need to add&amp;nbsp;fact_Staffing_schedule_scd[store_id]&amp;nbsp;=&amp;nbsp;&lt;SPAN class=""&gt;max_store filter inside CALCULATE but I don't understand the CALCULATETABLE part. What are yuou trying to acomplish?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;The numbers will be greater than expected at aggregated levels you are right about that. Actually the sum aggregation has no meaning. Therefore, please try with max aggregation&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;# staffing 2 :=
MAXX (
    CROSSJOIN ( VALUES ( dim_Date[DateID] ), VALUES ( dim_Stores[StoreID] ) ),
    VAR max_date = dim_Date[DateID]
    VAR max_store = dim_Stores[StoreID]
    VAR employees_count = [# employees]
    VAR stf_calc =
        CALCULATE (
            SUM ( fact_Staffing_schedule_scd[staffing_count] ),
            fact_Staffing_schedule_scd[store_id] = max_store,
            fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
            fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
        )
    RETURN
        IF ( employees_count &amp;gt; 0, stf_calc )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355709" data-lia-user-login="AntonL" class="lia-mention lia-mention-user"&gt;AntonL&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Mar 2023 18:33:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3126355#M111053</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-12T18:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: dax, value if measure on other table on same level data,store &gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3129012#M111255</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;, thank you again&lt;/P&gt;&lt;P&gt;i rewrite&amp;nbsp;you code a bit and almost received&amp;nbsp;estimated result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;# staffing 2:=
MAXX (
    CROSSJOIN ( VALUES ( dim_Date[DateID] ), VALUES ( dim_Stores[StoreID] ) ),
    VAR max_date = dim_Date[DateID]
    VAR max_store = dim_Stores[StoreID]
    VAR employees_count = [# employees]
    VAR stf_calc =
        CALCULATE (
            SUM ( fact_Staffing_schedule_scd[staffing_count] ),
            fact_Staffing_schedule_scd[store_id] = max_store,
            fact_Staffing_schedule_scd[date_fr] &amp;lt;= max_date,
            fact_Staffing_schedule_scd[date_to] &amp;gt; max_date
        )
    VAR stf_calc_r = IF (employees_count &amp;gt; 0, stf_calc )

    RETURN
        --max_date
        CALCULATE(stf_calc_r, dim_Date[DateID]=max_date)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and now main issue in that it on group level, for example month it shows value only for one store&lt;/P&gt;&lt;P&gt;due to&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            fact_Staffing_schedule_scd[store_id] = max_store,&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you please help to rewrite it to 'selected stores', not only one max/last&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 19:13:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3129012#M111255</guid>
      <dc:creator>AntonL</dc:creator>
      <dc:date>2023-03-13T19:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: dax, value if measure on other table on same level data,store &gt; 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3129027#M111256</link>
      <description>&lt;P&gt;&amp;nbsp;A variable is calculated only once. You cannot recalculate a variable inside CALCULATE. The expression:&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE&gt;CALCULATE(stf_calc_r, dim_Date[DateID]=max_date)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;does absolutely nothing&amp;nbsp;&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355709" data-lia-user-login="AntonL" class="lia-mention lia-mention-user"&gt;AntonL&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 19:21:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-value-if-measure-on-other-table-on-same-level-data-store-gt/m-p/3129027#M111256</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-13T19:21:37Z</dc:date>
    </item>
  </channel>
</rss>

