Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
I have 3 tables and their relationship as pic
How do I count row in table Document when:
- Document.CaseKey = ServicePeriod.CaseKey
- Document.Date <= ServicePeriod.EndDate
- Document.Date >= ServicePeriod.StartDate
Solved! Go to Solution.
Hi @Anonymous ,
Check the measures.
Measure =
var start_ = CALCULATE(MAX(ServicePeriod[start]),FILTER(ServicePeriod,ServicePeriod[casekey]=SELECTEDVALUE('case'[casekey])))
var end_ = CALCULATE(MAX(ServicePeriod[end]),FILTER(ServicePeriod,ServicePeriod[casekey]=SELECTEDVALUE('case'[casekey])))
return
IF(SELECTEDVALUE(document[casekey]) in VALUES(ServicePeriod[casekey])&&SELECTEDVALUE(document[date])>=start_&&SELECTEDVALUE(document[date])<=end_,1,0)
Measure 2 = SUMX(document,[Measure])
Best Regards,
Jay
Hi @Anonymous ,
Check the measures.
Measure =
var start_ = CALCULATE(MAX(ServicePeriod[start]),FILTER(ServicePeriod,ServicePeriod[casekey]=SELECTEDVALUE('case'[casekey])))
var end_ = CALCULATE(MAX(ServicePeriod[end]),FILTER(ServicePeriod,ServicePeriod[casekey]=SELECTEDVALUE('case'[casekey])))
return
IF(SELECTEDVALUE(document[casekey]) in VALUES(ServicePeriod[casekey])&&SELECTEDVALUE(document[date])>=start_&&SELECTEDVALUE(document[date])<=end_,1,0)
Measure 2 = SUMX(document,[Measure])
Best Regards,
Jay
Great.
Thanks a lot!
@Anonymous , Try a measure like
countx(values(case[Case key]), filter(Document, Document[CaseKey] = max(ServicePeriod[CaseKey]) && Document[Date] <= max(ServicePeriod[EndDate]) && Document[Date] >= min(ServicePeriod[StartDate])), [Case key])
Hi @amitchandak ,
I think the last [Case key] should not be there right? And without it, I got this warning "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value".
Cheers
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
75 | |
68 | |
41 | |
35 |
User | Count |
---|---|
102 | |
56 | |
52 | |
46 | |
40 |