Forum Discussion

POSPOS's avatar
POSPOS
Icon for Post Partisan rankPost Partisan
2 years ago

Count using DAX with page level filters

Hi,

I have a requirement to get three different count.

1. Total Count -- Sum of Active + Pending

2. Active Count -- Count of protocols with Active Date

3. Pending Count -- Count of protocols with blank Active Date

 

Sample Data:

Table 1:

Table 2:

 

Based on my requriement,I have a slicer and  I also have to apply page level filters as below:

I am unable to get the active count and total count. Pending count works fine. (Values should change based on slicer selection.)

 

Sample Pbix file is attached here.

 

Could someone pls help with the DAX for active count and total count?

Thank you.

13 Replies

  • HEllo POSPOS ,

     

    check if this is the desired result

     

     

    Active Protocols = 
    CALCULATE(DISTINCTCOUNT('Table'[Protocol]),ALL('Table'),'Table'[Active Date] <> BLANK())

     

    Total Count = 
    CALCULATE(DISTINCTCOUNT('Table'[Protocol]),ALL('Table'))
    • POSPOS's avatar
      POSPOS
      Icon for Post Partisan rankPost Partisan

      Idrissshatila 
      Values are as expected, but we also want the values  to change with slicers selection.
      Now, the values are not changing with slicer selection.

    • POSPOS's avatar
      POSPOS
      Icon for Post Partisan rankPost Partisan

      Idrissshatila 
      In the initial view the values for active count should show as 5 and when any slicer selections are made the value will be blank.

  • Anonymous's avatar
    Anonymous
    Not applicable

    POSPOS  Do these expressions work for you?

    Active Count =
    CALCULATE(
        COUNTAX('Table','Table'[Protocol]),
        KEEPFILTERS(
            NOT ISBLANK(
                'Table'[Active Date]
            )
        )
    )

    Pending Protocols =
    CALCULATE (
        COUNTAX ( 'Table', 'Table'[Protocol] ),
        KEEPFILTERS ( ISBLANK ( 'Table'[Active Date] ) )
    )

    Total Count =
    [Active Count] + [Pending Protocols]
    • POSPOS's avatar
      POSPOS
      Icon for Post Partisan rankPost Partisan

      Anonymous 
      With the logic for Active Count , I am getting blank. Could you please share the pbix file if possible