Forum Discussion

tb0493's avatar
tb0493
Frequent Visitor
3 years ago
Solved

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

ABCDE
2SAMPLE DATA-  ticket dataset
3DateTicket#Process TypeOther columns
41/2/2023100021passedOther details
51/3/2023100022bypassedOther details
61/4/2023100023bypassedOther details
71/5/2023100024bypassedOther details
81/6/2023100025bypassedOther details
91/7/2023100026bypassedOther details
101/8/2023100027passedOther details
111/9/2023100028passedOther details
121/10/2023100029passedOther details
132/1/2023100030bypassedOther details
142/2/2023100031bypassedOther details
152/3/2023100032bypassedOther details
162/4/2023100033bypassedOther details
172/5/2023100034passedOther details
182/6/2023100035passedOther details
192/7/2023100036passedOther details
202/8/2023100037bypassedOther details
212/9/2023100038bypassedOther details
222/10/2023100039bypassedOther details
232/11/2023100040bypassedOther 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 🙂

3 Replies

  • tb0493's avatar
    tb0493
    Frequent Visitor

    Thanks! I will give these a try. 🙂

  • 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
     

     

  • TheoC's avatar
    TheoC
    Community 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 🙂