Reputation: 1
Table 1 (Combined Hours) I have a list of [payweek], which is many repeated
Table 2 (All Scripts), I have a list of jobs and two dates, [Scripting Date] and [R4PreScriptDate]
I am trying to find the number of unique [payweek]s between the [Scripting Date] and the [R4PreScriptDate]
The DAX formula is below. My result is always 3. However, I am expecting variable answers (0,1, 2,3,4 or 5)
R4PreScriptWkCt = CALCULATE(DISTINCTCOUNTNOBLANK(CombinedHours[payWeek]),FILTER(CombinedHours,
CombinedHours[payWeek] <= MAX (AllScripts[Scripting Date] )
&& CombinedHours[payWeek] >= MAX (AllScripts[R4PreScriptDate] ) ))
Thank you,
Upvotes: 0
Views: 606
Reputation: 1206
I assumed that both tables are related by Job Number. I created the following measure:
R4PreScriptWkCt =
VAR __date2 = MAX ( AllScripts[R4PreScriptDate] )
VAR __date1 = MAX ( AllScripts[Scripting Date] )
VAR __job = MAX ( AllScripts[Job Number] )
VAR __subTable =
FILTER (
CombinedHours,
CombinedHours[Job Number] = __job
&& CombinedHours[Week] >= __date1
&& CombinedHours[Week] <= __date2
)
RETURN
CALCULATE ( DISTINCTCOUNTNOBLANK ( CombinedHours[Week] ), __subTable )
Hope it helps you.
Upvotes: 0