Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Haripoola
Frequent Visitor

Count values over a period

Hi team,

I have a fact table which contains Student's details like below (attached sample copy), 
I'm trying to create a DAX expression that will enable me to return data when a student failed/passed status is in between a selected date range.
For example consider HARRY Data from below table When i select a date range of 01/01/19 to 31/05/21 using a date slicer, He should be treated as failed student and his count should be in Failed count, If i move slicer to 06/01/21 His count should be removed from Failed count and should be added in Passed student as he passed the exam on 06/01/21.
Please let me know if needed more information.

 

Haripoola_0-1646595016293.png

 

4 REPLIES 4
v-rongtiep-msft
Community Support
Community Support

Hi @Haripoola ,

Does that make sense? If so, kindly mark my answer as the solution to close the case and help more people find the answer please. Thanks in advance. Or if you have resolved the issue, please share your way.

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-rongtiep-msft
Community Support
Community Support

Hi @Haripoola , 

Please refer to my pbix file to see if it helps you.

Create a measure.

 

Measure= calculate(DISTINCTCOUNT('Table'[StudentID]),FILTER(('Table'),'Table'[ExamStatus]=SELECTEDVALUE('Table'[ExamStatus])))

 

vpollymsft_0-1648106927802.png

vpollymsft_1-1648106942123.png

 

 

 

 

 

 

If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output.

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

amitchandak
Super User
Super User

@Haripoola , Refer

 

meausre =
var _max = maxx(filter(allselected(Table), Table[StudentID] = max(Table[StudentID])), Table[StudentUpdatedon])
return
calculate(count(Table[StudentID]), filter(Table, Table[StudentUpdatedon] =_max))

 

or


Measure =
VAR __id = MAX ('Table'[StudentID] )
VAR __date = CALCULATE ( MAX('Table'[StudentUpdatedon] ), ALLSELECTED ('Table' ), 'Table'[StudentID] = __id )
CALCULATE (count(Table[StudentID]), VALUES ('Table'[StudentID] ),'Table'[StudentID] = __id,'Table'[StudentUpdatedon] = __date )

@amitchandak 

Thank you for your solution and I think it works for my requirement.

Could you please suggest me how to calculate with combination of StudentID and StudentName.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors