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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
thinker_02
Regular Visitor

Count column, filtered by measure

I want to create a measure to count Product ID where Status on latest date is high.

Product ID is a column.

Status on latest date is a measure.

 

Snapshot of the Profit table:

| Product ID | Date | Status |
|------------|------------|--------|
| ID1 | 4/4/2022 | Low |
| ID2 | 8/1/2022 | High |
| ID1 | 10/12/2022 | High |
| ID1 | 2/1/2022 | Medium |
| ID2 | 1/1/2023 | Low |
| ID2 | 6/7/2022 | Medium |
| ID1 | 7/7/2023 | Medium |

Three measures were created for analysis:

 Min Date: 6/12/2022 and Max Date: 4/2/2023 (I selected them in Date Slicer too)

Measures are-

 

Latest date = MAX(Data[Date])
 
Second date = CALCULATE(MAX(Data[Date]),CALCULATETABLE(LASTNONBLANK('Calendar'[Date],CALCULATE([Latest date])),DATESBETWEEN('Calendar'[Date],MINX(ALL('Calendar'),'Calendar'[Date]),[Latest date]-1)))
 
Status on latest date = CALCULATE(MIN(Data[Status]),DATESBETWEEN('Calendar'[Date],[Latest date],[Latest date]))
 
Status on second date = CALCULATE(MAX(Data[Status]),DATESBETWEEN('Calendar'[Date],[Second date],[Second date]))
 
Many thanks in advance.

thinker_02_0-1707256459576.png

 



2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @thinker_02 

 

Please try this:

I create a new table:

vzhengdxumsft_0-1707290863669.png

Then Create a measure:

CountID = 
	VAR _Newvalue = SELECTEDVALUE('Table 2'[Value])
	VAR _countID = SWITCH(
		_Newvalue,
		"Count1", "ID1",
		"Count2", "ID2"
	)
	RETURN
		CALCULATE(
			COUNTROWS('Data'),
			FILTER(
				ALLSELECTED('Data'),
				'Data'[Status] = "High" && 'Data'[Product ID] = _countID
			)
		)

The result is as follow:

vzhengdxumsft_1-1707291046998.pngvzhengdxumsft_2-1707291056409.pngvzhengdxumsft_3-1707291069241.png

 

Best Regards,

Zhengdong Xu

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

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

I had shared those measures in another post with you.  You should have ideally continued asking your question in the same thread.  Try this measure

Measure = countrows(Data[Product ID]),[Status on latest date]="High")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

I had shared those measures in another post with you.  You should have ideally continued asking your question in the same thread.  Try this measure

Measure = countrows(Data[Product ID]),[Status on latest date]="High")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
thinker_02
Regular Visitor

@Anonymous Can you attach the PBIX file pls? I tried to do same but didnt work.  I have multiple IDs in data such as ID1, ID2, ID3, ID4 etc. I must be missing something. Many thanks.

Anonymous
Not applicable

Hi @thinker_02 

 

Here is the pbix file:

 

Best Regards,

Zhengdong Xu

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

 

Anonymous
Not applicable

Hi @thinker_02 

 

Please try this:

I create a new table:

vzhengdxumsft_0-1707290863669.png

Then Create a measure:

CountID = 
	VAR _Newvalue = SELECTEDVALUE('Table 2'[Value])
	VAR _countID = SWITCH(
		_Newvalue,
		"Count1", "ID1",
		"Count2", "ID2"
	)
	RETURN
		CALCULATE(
			COUNTROWS('Data'),
			FILTER(
				ALLSELECTED('Data'),
				'Data'[Status] = "High" && 'Data'[Product ID] = _countID
			)
		)

The result is as follow:

vzhengdxumsft_1-1707291046998.pngvzhengdxumsft_2-1707291056409.pngvzhengdxumsft_3-1707291069241.png

 

Best Regards,

Zhengdong Xu

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors