Forum Discussion
Giavo
7 years agoHelper III
DAX: SELECTEDVALUE with Dates
Hello all, INTRO: i have a Relational model with 3 tables: 1)Project Milestones table containing Project Codes and 4 dates per each project (Date1, Date2, Date3, Date4) 2)Projects Table cont...
- 7 years ago
Giavo I am just looking for sample data not actual data, but anyway I guess you are looking for this..
Test122Count =
VAR _SelectedYear = SELECTEDVALUE(_DimDate[Year])
VAR _Temp = FILTER(Test122,
((YEAR(Test122[Date1])<=_SelectedYear || YEAR(Test122[Date2])<=_SelectedYear) && (YEAR(Test122[Date3])>=_SelectedYear || YEAR(Test122[Date4])>=_SelectedYear)))
VAR _Temp1 = IF(COUNTROWS(_Temp)>0,1,0)
RETURN SUMX(_Temp,_Temp1) - 7 years ago
Hi Giavo,
I think the following formula should do what you expect, essentially it will count the rows on the 'Project Milestones' table where the conditions are met based on the selected value
Active in X = VAR SelectedYear=SELECTEDVALUE('Calendar'[Year]) RETURN Calculate(CountRows('Project Milestones'), FILTER('Project Milestones', (YEAR(Date 1)<=SelectedYear || YEAR(Date 2)<=SelectedYear) && (YEAR(Date 3)>= SelectedYear || YEAR(Date 4)>=SelectedYear)))
v-juanli-msft
7 years agoCommunity Support
Hi Giavo
As tested, PattemManohar's solution is helpful, could you check it on your site, if you have problem please don't hesitate to ask.
Best Regards
Maggie
Giavo
7 years agoHelper III
just replied
- richbenmintz7 years agoResident Rockstar
Hi Giavo,
I think the following formula should do what you expect, essentially it will count the rows on the 'Project Milestones' table where the conditions are met based on the selected value
Active in X = VAR SelectedYear=SELECTEDVALUE('Calendar'[Year]) RETURN Calculate(CountRows('Project Milestones'), FILTER('Project Milestones', (YEAR(Date 1)<=SelectedYear || YEAR(Date 2)<=SelectedYear) && (YEAR(Date 3)>= SelectedYear || YEAR(Date 4)>=SelectedYear)))