Forum Discussion
Count Row's with Multiple Filters
Hi, I wonder if anyone can help.
I am trying to do a count of rows if the True Driver Type = 1, and then legheaderdriver 1, Week Number and Year all equal the value currently in the row.
I feel like I'm close, but my current formula I've put in specific filter criteria for.
I thought it would be something like this, but it doesnt work:
Please can someone help. Thanks!
- Anonymous5 years ago
Hi clarkey1988 ,
According to my understanding, you want to add a column for calculating the count of rows grouped by four columns(True Driver Type,LegHeaderDriver1,Week Number,Year), right?
You could use the following formula:
Column = CALCULATE ( COUNTROWS ( 'Trip Detail' ), ALLEXCEPT ( 'Trip Detail', 'Trip Detail'[True Driver Type], 'Trip Detail'[LegHeaderDriver1], 'Trip Detail'[Week Number], 'Trip Detail'[Year] ) )Here is the pbix file.
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7 Replies
- Ashish_MathurSuper User
Hi,
If you have already applied filter/slicers on the page or the visual, then you do not need to specify those again in the measure. So this simple measure should work
=COUNTROWS('Trip Detail')
If you have not applied filters/slicers on the page or the visual and would like to specify those in the measure instead, then the measure should be
=CALCULATE(COUNTROWS('Trip Detail'),'Trip Detail'[True Driver Type]=1,'Trip Detail'[LegHeaderDriver1]="MUNJO",'Trip Detail'[Week Number]=4,'Trip Detail'[Year]=2021)
Hope this helps.
- clarkey1988Helper II
Hi Ashish - thank you for your response,
I need this to be in a calculated column. The values typed in such as "Munjo", week number "4" and year "2021" I need to be the values that are actually in the current row. Without me typing them in.
- Ashish_MathurSuper User
Hi,
Try this calculated column formula
=CALCULATE(COUNTROWS('Trip Detail'),filter('Trip Detail','Trip Detail'[True Driver Type]=earlier('Trip Detail'[True Driver Type]),'Trip Detail'[LegHeaderDriver1]=earlier('Trip Detail'[LegHeaderDriver1]),'Trip Detail'[Week Number]=earlier('Trip Detail'[Week Number]),'Trip Detail'[Year]=earlier('Trip Detail'[Year])))
- clarkey1988Helper II
Essentially, I'm trying to replicate the below count ifs
- AnonymousNot applicable
Hi clarkey1988 ,
According to my understanding, you want to add a column for calculating the count of rows grouped by four columns(True Driver Type,LegHeaderDriver1,Week Number,Year), right?
You could use the following formula:
Column = CALCULATE ( COUNTROWS ( 'Trip Detail' ), ALLEXCEPT ( 'Trip Detail', 'Trip Detail'[True Driver Type], 'Trip Detail'[LegHeaderDriver1], 'Trip Detail'[Week Number], 'Trip Detail'[Year] ) )Here is the pbix file.
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- clarkey1988Helper II
Hi Anonymous ,
I was out of the office last week. That is very close. However, I only want to count the rows if the true driver type value is the number 1.
- AnonymousNot applicable
Hi clarkey1988 ,
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it.Best Regards,
Eyelyn Qin