Forum Discussion
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.
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]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 _resultIf 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.
5 Replies
- Greg_DecklerCommunity 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) - amitchandakSuper 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.
- AnonymousNot applicable
Sample data is something like this:
id of meeting date 6247 2020-09-10 11:07:56.000000 5762 2021-07-07 10:30:00.000000 9856 2021-03-17 10:30:00.000000 4567 2021-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.
- v-zhenbw-msftCommunity Support
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]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 _resultIf 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.