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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
arviaus
Regular Visitor

Disctinct count the number of Items with criteria using the latest assessment date

Hi all,

 

very new to Power BI and just starting to use measures. What would be my formula if I want to show a visual that shows items with a fail result using their latest assessment date.

 

DepartmentItemAssessment dateAssessment Result
1a1/01/2021Pass
1a1/01/2022Pass
1b1/01/2021Fail
1b  
1c1/01/2021Pass
1c1/01/2022Fail
2a1/01/2021Pass
2a1/01/2022Pass
2b1/01/2021Pass
2b1/01/2022Pass
2c1/01/2021Fail
2c1/01/2022Fail
3a1/01/2021Fail
3a1/01/2022Pass
3b1/01/2021Fail
3b1/01/2022Fail
3c1/01/2020Pass
3c1/01/2021Fail

 

An output using above which I wanted to show using bar graph as follows

DepartmentCount of Fails
12
21
32

 

Thanks.

 

 

1 ACCEPTED SOLUTION

@arviaus 

Use this measure:

Count = 
VAR __T = 	
	ADDCOLUMNS(
		SUMMARIZE( Table03 , Table03[Department] , Table03[Item]),
		"Status" , 
		VAR __MaxDate = CALCULATE( MAX( Table03[Assessment date] ) )	
		VAR __Result = CALCULATE( MAX( Table03[Assessment Result] ) , Table03[Assessment date] = __MaxDate )
		RETURN
			INT( __Result = "Fail" )
	)
VAR __Result = 
	SUMX( __T , [Status] )
RETURN
	__Resul

 

Fowmy_0-1702623826507.png

 




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User

@arviaus 

Please verify your expected output. 

Example:
Dep 3 should give you 3 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

No, Dep 3 should be 2, because item a's latest assessment is 2022 and is a Pass.

@arviaus 

Use this measure:

Count = 
VAR __T = 	
	ADDCOLUMNS(
		SUMMARIZE( Table03 , Table03[Department] , Table03[Item]),
		"Status" , 
		VAR __MaxDate = CALCULATE( MAX( Table03[Assessment date] ) )	
		VAR __Result = CALCULATE( MAX( Table03[Assessment Result] ) , Table03[Assessment date] = __MaxDate )
		RETURN
			INT( __Result = "Fail" )
	)
VAR __Result = 
	SUMX( __T , [Status] )
RETURN
	__Resul

 

Fowmy_0-1702623826507.png

 




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Ritaf1983
Super User
Super User

Hi @arviaus 
Use dax code :

Fails = calculate( distinctcount('yourtable'[Item]), 'yourtable'[ Assessment]="Fail" )

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

Thanks for the reply; however, this does not take into account the latest date for each item.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.