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! Request now

Reply
Anonymous
Not applicable

How to count until a certain value is reached

Hi! 

I am a beginner in Power BI Desktop and I kindly ask you to help me with a particular DAX formula.

 

I have a column with meetings ID and there can be only 2 meetings per quarter. How can I count them until 2 is reached? So, that means only two of the earliest meetings are counted and those which were arranged later are not counted. 
I hope I explained the task clearly. 
Thank you in advance. 
1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

We can create three columns and a measure to meet your requirement.

 

1. Create year column, quarter column and year & quarter column.

 

Year = YEAR('Table'[Date])
Quarter = QUARTER('Table'[Date])
Year & Quarter = 'Table'[Year] &"-Q"& 'Table'[Quarter]

 

how to1.jpg

 

2. Create a measure and the result like this,

 

Measure = 
var _count = COUNT('Table'[id of meeting])
var _result = 
IF(
    _count>2,2,_count)
return
_result

 

how to2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , if you have date we can have measure like with date Table

 

measure =
var _qtr =CALCULATE(Count(Table[meeting ID]),DATESQTD(('Date'[Date])))

return
sumx(values(Date[Qtr-year]),if(_qtr >=2,2,_qtr))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Sample data is something like this:

id of meetingdate
62472020-09-10 11:07:56.000000
57622021-07-07 10:30:00.000000
98562021-03-17 10:30:00.000000
45672021-04-28 10:30:00.000000

I also have other table connected where are boolean fields like IS CURRENT FQ, FIRST DAY OF FQ, LAST DAY OF FQ.

So, I need to count only the first 2 meetings of each quarter. When the count reaches 2, it stops counting. 

 

Hi,

Try this approach:

  1. Using the Query Editor, remove the time stamps from the date column
  2. Create a Calendar Table and write calculated column formulas to extract Year, Month Name, Month number and Quarter.  Using the "Sort By" feature, sort the Month name column by Month number
  3. Create a relationship from the Date column of your dataset (from where you have removed the time stamp) to the Date column of your Date table
  4. To your visual, drag the Year and Quarter from the Calendar Table
  5. Write this measures

=IF(COUNTROWS(Data)>2,2,COUNTROWS(Data))

Hope this helps.


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

Hi @Anonymous ,

 

We can create three columns and a measure to meet your requirement.

 

1. Create year column, quarter column and year & quarter column.

 

Year = YEAR('Table'[Date])
Quarter = QUARTER('Table'[Date])
Year & Quarter = 'Table'[Year] &"-Q"& 'Table'[Quarter]

 

how to1.jpg

 

2. Create a measure and the result like this,

 

Measure = 
var _count = COUNT('Table'[id of meeting])
var _result = 
IF(
    _count>2,2,_count)
return
_result

 

how to2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Greg_Deckler
Community Champion
Community Champion

@Anonymous Sample data would be great, but you could count rows that are earlier than the current row but greater than the start of the quarter like:

Column = 
  VAR __Table = FILTER('Table',[Date]<=EARLIER([Date] && [Quarter] = EARLIER([Quarter]) && [Year]=EARLIER([Year]))
RETURN
  COUNTROWS(__Table)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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
Top Kudoed Authors