<?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 Calculate values at different granular in DAX measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4282602#M169962</link>
    <description>&lt;P&gt;I am struggling on creating a DAX measure to solve below problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to filter on below dataset where dim_reporting_date_key is the latest date for each dim_case_key with a quarter, then counting how many cases at "Age Over Time" level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only show partially data here as the full dataset is big.&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script should like below if I use SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;select [Age Over Time],
       count(distinct dim_case_key) as result
from
(
    select dim_case_key,
           dim_reporting_date_key,
           [Case Status],
           [Open Days],
           [Age Over Time],
           max(dim_reporting_date_key) OVER (PARTITION BY dim_case_key) as LatestDate
    from #temp2
) x
where dim_reporting_date_key = [LatestDate]
group by [Age Over Time]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my dax measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// DAX Query
DEFINE
	VAR __Filter =
	TREATAS(
		{
			20240731,
			20240831,
			20240930
		},
		'Fact Case Monthly Snapshot'[dim_reporting_date_key]
	)

	MEASURE 'Fact Case Monthly Snapshot'[LDate] = (
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		)
	MEASURE 'Fact Case Monthly Snapshot'[Result] =

		VAR latestDate =
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		VAR latestValue =
		CALCULATE(
			DISTINCTCOUNT('Fact Case Monthly Snapshot'[dim_case_key]),
			FILTER(
				'Fact Case Monthly Snapshot',
				'Fact Case Monthly Snapshot'[dim_reporting_date_key] = latestDate
			)
		)

		RETURN
			SUMX(
				SUMMARIZE(
					'Fact Case Monthly Snapshot',
					'Fact Case Monthly Snapshot'[dim_case_key],
					"LatestValue", latestValue
				),
				[LatestValue]
			)
			


	VAR __DS0Core =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[dim_case_key],
		'Fact Case Monthly Snapshot'[dim_reporting_date_key],
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

	VAR __DS0Core2 =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

EVALUATE

	// __DS0Core
	// ORDER BY
	// 	'Fact Case Monthly Snapshot'[dim_case_key],
	// 	'Fact Case Monthly Snapshot'[dim_reporting_date_key] DESC


	__DS0Core2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is incorrect. The value of result is too high.&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;If I run the measure at case granular and the result looks good.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// DAX Query
DEFINE
	VAR __Filter =
	TREATAS(
		{
			20240731,
			20240831,
			20240930
		},
		'Fact Case Monthly Snapshot'[dim_reporting_date_key]
	)

	MEASURE 'Fact Case Monthly Snapshot'[LDate] = (
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		)
	MEASURE 'Fact Case Monthly Snapshot'[Result] =

		VAR latestDate =
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		VAR latestValue =
		CALCULATE(
			DISTINCTCOUNT('Fact Case Monthly Snapshot'[dim_case_key]),
			FILTER(
				'Fact Case Monthly Snapshot',
				'Fact Case Monthly Snapshot'[dim_reporting_date_key] = latestDate
			)
		)

		RETURN
			SUMX(
				SUMMARIZE(
					'Fact Case Monthly Snapshot',
					'Fact Case Monthly Snapshot'[dim_case_key],
					"LatestValue", latestValue
				),
				[LatestValue]
			)
			


	VAR __DS0Core =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[dim_case_key],
		'Fact Case Monthly Snapshot'[dim_reporting_date_key],
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

	VAR __DS0Core2 =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

EVALUATE

	__DS0Core
	ORDER BY
	'Fact Case Monthly Snapshot'[dim_case_key],
	'Fact Case Monthly Snapshot'[dim_reporting_date_key] DESC


	// __DS0Core2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result shows 1 for the correct records and blank for others.&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 am not sure where is wrong of my measure and why the result is aggregated incorrectly. Can someone help me to solve this issue please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2024 22:52:23 GMT</pubDate>
    <dc:creator>whjqb</dc:creator>
    <dc:date>2024-11-13T22:52:23Z</dc:date>
    <item>
      <title>Calculate values at different granular in DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4282602#M169962</link>
      <description>&lt;P&gt;I am struggling on creating a DAX measure to solve below problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to filter on below dataset where dim_reporting_date_key is the latest date for each dim_case_key with a quarter, then counting how many cases at "Age Over Time" level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only show partially data here as the full dataset is big.&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script should like below if I use SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;select [Age Over Time],
       count(distinct dim_case_key) as result
from
(
    select dim_case_key,
           dim_reporting_date_key,
           [Case Status],
           [Open Days],
           [Age Over Time],
           max(dim_reporting_date_key) OVER (PARTITION BY dim_case_key) as LatestDate
    from #temp2
) x
where dim_reporting_date_key = [LatestDate]
group by [Age Over Time]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my dax measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// DAX Query
DEFINE
	VAR __Filter =
	TREATAS(
		{
			20240731,
			20240831,
			20240930
		},
		'Fact Case Monthly Snapshot'[dim_reporting_date_key]
	)

	MEASURE 'Fact Case Monthly Snapshot'[LDate] = (
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		)
	MEASURE 'Fact Case Monthly Snapshot'[Result] =

		VAR latestDate =
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		VAR latestValue =
		CALCULATE(
			DISTINCTCOUNT('Fact Case Monthly Snapshot'[dim_case_key]),
			FILTER(
				'Fact Case Monthly Snapshot',
				'Fact Case Monthly Snapshot'[dim_reporting_date_key] = latestDate
			)
		)

		RETURN
			SUMX(
				SUMMARIZE(
					'Fact Case Monthly Snapshot',
					'Fact Case Monthly Snapshot'[dim_case_key],
					"LatestValue", latestValue
				),
				[LatestValue]
			)
			


	VAR __DS0Core =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[dim_case_key],
		'Fact Case Monthly Snapshot'[dim_reporting_date_key],
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

	VAR __DS0Core2 =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

EVALUATE

	// __DS0Core
	// ORDER BY
	// 	'Fact Case Monthly Snapshot'[dim_case_key],
	// 	'Fact Case Monthly Snapshot'[dim_reporting_date_key] DESC


	__DS0Core2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is incorrect. The value of result is too high.&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;If I run the measure at case granular and the result looks good.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// DAX Query
DEFINE
	VAR __Filter =
	TREATAS(
		{
			20240731,
			20240831,
			20240930
		},
		'Fact Case Monthly Snapshot'[dim_reporting_date_key]
	)

	MEASURE 'Fact Case Monthly Snapshot'[LDate] = (
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		)
	MEASURE 'Fact Case Monthly Snapshot'[Result] =

		VAR latestDate =
		CALCULATE(
			MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
			ALLSELECTED(
				'Fact Case Monthly Snapshot'[dim_reporting_date_key],
				'Fact Case Monthly Snapshot'[Age Over Time]
			)
		)
		VAR latestValue =
		CALCULATE(
			DISTINCTCOUNT('Fact Case Monthly Snapshot'[dim_case_key]),
			FILTER(
				'Fact Case Monthly Snapshot',
				'Fact Case Monthly Snapshot'[dim_reporting_date_key] = latestDate
			)
		)

		RETURN
			SUMX(
				SUMMARIZE(
					'Fact Case Monthly Snapshot',
					'Fact Case Monthly Snapshot'[dim_case_key],
					"LatestValue", latestValue
				),
				[LatestValue]
			)
			


	VAR __DS0Core =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[dim_case_key],
		'Fact Case Monthly Snapshot'[dim_reporting_date_key],
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

	VAR __DS0Core2 =
	SUMMARIZECOLUMNS(
		'Fact Case Monthly Snapshot'[Age Over Time],
		__Filter,
		"Result", 'Fact Case Monthly Snapshot'[Result],
		"Latest Date", [LDate]
	)

EVALUATE

	__DS0Core
	ORDER BY
	'Fact Case Monthly Snapshot'[dim_case_key],
	'Fact Case Monthly Snapshot'[dim_reporting_date_key] DESC


	// __DS0Core2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result shows 1 for the correct records and blank for others.&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 am not sure where is wrong of my measure and why the result is aggregated incorrectly. Can someone help me to solve this issue please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2024 22:52:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4282602#M169962</guid>
      <dc:creator>whjqb</dc:creator>
      <dc:date>2024-11-13T22:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate values at different granular in DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4283120#M169995</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="692735" data-lia-user-login="whjqb" class="lia-mention lia-mention-user"&gt;whjqb&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems the issue you're facing is due to an incorrect aggregation, which results in higher values than expected. This can happen if the calculation isn’t properly limited to the latest date per dim_case_key. In your case, the key is to ensure that you’re only counting each dim_case_key once at its latest reporting date.&lt;/P&gt;&lt;P&gt;Here’s an approach to modify your DAX to make sure you only count each case on the latest reporting date:&lt;/P&gt;&lt;H3&gt;Solution&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Identify the Latest Date Per Case&lt;/STRONG&gt;: Create a variable to capture the latest date per dim_case_key.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Filter for Latest Date&lt;/STRONG&gt;: Use this variable in a filter to make sure only cases with their latest date are counted.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Count Distinct Cases&lt;/STRONG&gt;: Finally, count the distinct cases based on the filtered table.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here’s how this DAX measure could look:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Result = 
VAR LatestDatePerCase =
    CALCULATE(
        MAX('Fact Case Monthly Snapshot'[dim_reporting_date_key]),
        ALLEXCEPT('Fact Case Monthly Snapshot', 'Fact Case Monthly Snapshot'[dim_case_key])
    )

RETURN
    CALCULATE(
        DISTINCTCOUNT('Fact Case Monthly Snapshot'[dim_case_key]),
        'Fact Case Monthly Snapshot'[dim_reporting_date_key] = LatestDatePerCase,
        TREATAS(
            {20240731, 20240831, 20240930},
            'Fact Case Monthly Snapshot'[dim_reporting_date_key]
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;Explanation&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;LatestDatePerCase&lt;/STRONG&gt;: This variable calculates the latest dim_reporting_date_key for each dim_case_key, ignoring other filters.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;DISTINCTCOUNT with Filter&lt;/STRONG&gt;: We then use DISTINCTCOUNT to count distinct cases only where dim_reporting_date_key matches LatestDatePerCase for each dim_case_key. The TREATAS function is used to apply the filter to include only relevant dates.&lt;/LI&gt;&lt;/OL&gt;&lt;H3&gt;Additional Tips&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Avoid Nested Aggregation Issues&lt;/STRONG&gt;: Summing up DISTINCTCOUNT results can sometimes lead to inflated counts, so the approach here directly applies the date filter within the calculation.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Debugging with Intermediate Tables&lt;/STRONG&gt;: If you're still having trouble, try using SUMMARIZE or ADDCOLUMNS to create intermediate tables for debugging and verify the date filtering step-by-step.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This should ensure that your measure correctly counts each dim_case_key only once on its latest date. Let me know if this provides the correct result or if further adjustments are needed!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;BR /&gt;&lt;STRONG&gt;YouTube&lt;/STRONG&gt;: &lt;A href="https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS" target="_blank" rel="noopener"&gt;https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 06:06:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4283120#M169995</guid>
      <dc:creator>Poojara_D12</dc:creator>
      <dc:date>2024-11-14T06:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate values at different granular in DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4283414#M170005</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="692735" data-lia-user-login="whjqb" class="lia-mention lia-mention-user"&gt;whjqb&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply from&amp;nbsp;Poojara_D12&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have created the following measure to calculate LatestDate,&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LatestDate = CALCULATE(MAX([dim_reporting_date_key]), 'Fact Case Monthly Snapshot'[dim_case_key] = MAX([dim_case_key]))&lt;/LI-CODE&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;but I have some questions about the result of count. What is the calculation logic of count? Is it to get the maximum date of each Age Over time, and if there is a maximum date of dim_case_key that is the same as it, then count it? Could you please give the expected result based on the sample data you provided so that we can better help you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yulia Xu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt; &lt;/EM&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 08:01:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4283414#M170005</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-14T08:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate values at different granular in DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4284683#M170056</link>
      <description>&lt;P&gt;Hi Yulia,&lt;/P&gt;&lt;P&gt;Thanks for your help. Here is more explanation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"max_date" is the maximum dim_reporting_date_key for each dim_case_key. "Selected" is Y if dim_reporting_date_key = max_date. I would like to select those "Y" records and ignore others.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would like to aggregate to Age Over Time level and count distinct number of&amp;nbsp; dim_case_key. So the expected result should be like this.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ming&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>Thu, 14 Nov 2024 21:15:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4284683#M170056</guid>
      <dc:creator>whjqb</dc:creator>
      <dc:date>2024-11-14T21:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate values at different granular in DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4284685#M170058</link>
      <description>&lt;P&gt;Hi Poojara,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also want to aggregate the filtered dataset to Age Over Time level and count the distinct numbers of dim_case_key. More explanations are in my reply to&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ming&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 21:17:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4284685#M170058</guid>
      <dc:creator>whjqb</dc:creator>
      <dc:date>2024-11-14T21:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate values at different granular in DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4303848#M170891</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="692735" data-lia-user-login="whjqb" class="lia-mention lia-mention-user"&gt;whjqb&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to apologize for the belated reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try the following measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;max_date = CALCULATE(MAX([dim_reporting_date_key]), ALLEXCEPT('Table', 'Table'[dim_case_key]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Selected = IF(MAX([dim_reporting_date_key]) = [max_date], "Y", "NULL")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;result = CALCULATE(DISTINCTCOUNT('Table'[dim_case_key]), FILTER(ALLEXCEPT('Table', 'Table'[Age Over Time]), [Selected] = "Y"))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the result I get is different from yours, according to the screenshot you provided, the result of "60-90" should be 7, not 11. But I think it's because the sample data is incomplete. If you have any questions, please feel free to let me know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yulia Xu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2024 09:23:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4303848#M170891</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-27T09:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate values at different granular in DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4304832#M170934</link>
      <description>&lt;P&gt;Hi Yulia,&lt;/P&gt;&lt;P&gt;Thanks for your response. However, your solution does not work for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also need to add slicer for dim_reporting_date_key to let user dynamic select months. If I select July and Aug, then the max date should be 20240831 for dim_case_key 101388. I tried to add keepfilters in the measures but it is still giving me wrong number.&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;</description>
      <pubDate>Wed, 27 Nov 2024 20:41:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-at-different-granular-in-DAX-measure/m-p/4304832#M170934</guid>
      <dc:creator>whjqb</dc:creator>
      <dc:date>2024-11-27T20:41:20Z</dc:date>
    </item>
  </channel>
</rss>

