Forum Discussion
Using "Count" function in DAX for attribute data
Hello, I'm trying to figure out how to perform these Excel formulas in DAX, I'm thinking it's either using COUNTX or COUNTAX and then getting the percent in a visual. Any help would be appreciated.
Here is a sample data set
| A | B | C | D | E |
| 2 | SAMPLE DATA- ticket dataset | |||
| 3 | Date | Ticket# | Process Type | Other columns |
| 4 | 1/2/2023 | 100021 | passed | Other details |
| 5 | 1/3/2023 | 100022 | bypassed | Other details |
| 6 | 1/4/2023 | 100023 | bypassed | Other details |
| 7 | 1/5/2023 | 100024 | bypassed | Other details |
| 8 | 1/6/2023 | 100025 | bypassed | Other details |
| 9 | 1/7/2023 | 100026 | bypassed | Other details |
| 10 | 1/8/2023 | 100027 | passed | Other details |
| 11 | 1/9/2023 | 100028 | passed | Other details |
| 12 | 1/10/2023 | 100029 | passed | Other details |
| 13 | 2/1/2023 | 100030 | bypassed | Other details |
| 14 | 2/2/2023 | 100031 | bypassed | Other details |
| 15 | 2/3/2023 | 100032 | bypassed | Other details |
| 16 | 2/4/2023 | 100033 | bypassed | Other details |
| 17 | 2/5/2023 | 100034 | passed | Other details |
| 18 | 2/6/2023 | 100035 | passed | Other details |
| 19 | 2/7/2023 | 100036 | passed | Other details |
| 20 | 2/8/2023 | 100037 | bypassed | Other details |
| 21 | 2/9/2023 | 100038 | bypassed | Other details |
| 22 | 2/10/2023 | 100039 | bypassed | Other details |
| 23 | 2/11/2023 | 100040 | bypassed | Other details |
Here are the excel formulas with results
Hi tb0493
You can use the following:1. Count all records = COUNTROWS ( 'TableName' )
2. Count if records "bypassed" =CALCULATE (
[Count all records] ,
FILTER ( 'TableName' , TableName[Processed Type] = "bypassed" ) )
3. Divide = DIVIDE ( [Count if records "bypassed"] , [Count all records] , 0 )
Attached is a PBIX File to assist.
Hope this helps 🙂
Thanks! I will give these a try. 🙂
3 Replies
- tb0493Frequent Visitor
Thanks! I will give these a try. 🙂
- andhiii079845Solution Sage
Try this:
Measure =VAR _all = COUNTAX(ALLSELECTED('Table'),'Table'[Ticket#])VAR _bypassed = COUNTAX(FILTER(ALLSELECTED('Table'),'Table'[Process Type]="bypassed"),'Table'[Ticket#])RETURN _bypassed/_all - TheoCCommunity Champion
Hi tb0493
You can use the following:1. Count all records = COUNTROWS ( 'TableName' )
2. Count if records "bypassed" =CALCULATE (
[Count all records] ,
FILTER ( 'TableName' , TableName[Processed Type] = "bypassed" ) )
3. Divide = DIVIDE ( [Count if records "bypassed"] , [Count all records] , 0 )
Attached is a PBIX File to assist.
Hope this helps 🙂