Forum Discussion

Marinus's avatar
Marinus
Helper I
1 year ago
Solved

Countrows without selection

I have a command to countrows with a specific tekst :

CALCULATE(
COUNTROWS('Overzicht aanvragen'),
'Overzicht aanvragen'[Aanvraag_Routelint] IN { "Zvg -", "Vlgr -", "Rsdg -", "Odzg -", "Edng -", "Bdlg -", "Svgg -" }
)

 

Can someone tell me how i can countrows without this specific tekst.

I can't find any DAX code that explains how to do this (i coultn't find the "IN" code too).

  • Hi Marinus,

    Thanks for your update.

     

    I’ve reproduced your scenario using sample data matching your raw data structure and achieved the expected output. Create the fallowing dax measure to calculate countrows.

     

    rows = CALCULATE(
    COUNTROWS(
    FILTER(ALL('table'),
    NOT('table'[Aanvraag_Routelint] IN { "Zvg -", "Vlgr -", "Rsdg -", "Odzg -", "Edng -", "Bdlg -", "Svgg -" })
    )
    )
    )

    The .pbix file attached demonstrates this working solution with your sample data.

     

    If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
    Thank you.

7 Replies

  • Marinus , Try using

    DAX
    CALCULATE(
    COUNTROWS('Overzicht aanvragen'),
    EXCEPT(
    ALL('Overzicht aanvragen'),
    FILTER(
    'Overzicht aanvragen',
    'Overzicht aanvragen'[Aanvraag_Routelint] IN { "Zvg -", "Vlgr -", "Rsdg -", "Odzg -", "Edng -", "Bdlg -", "Svgg -" }
    )
    )
    )

  • The result is a total of the column, but not the amount of rows without these specific text

  • Marinus Have you tried NOT and IN

    dax
    CALCULATE(
    COUNTROWS(
    FILTER(
    'Overzicht aanvragen',
    NOT('Overzicht aanvragen'[Aanvraag_Routelint] IN { "Zvg -", "Vlgr -", "Rsdg -", "Odzg -", "Edng -", "Bdlg -", "Svgg -" })
    )
    )
    )

    • Marinus's avatar
      Marinus
      Helper I

      This gives still a total of rows in the column, it includes the rows with the selected text.

      It should count the rows without the rows with the selected text.

  • v-ssriganesh's avatar
    v-ssriganesh
    Community Support

    Hello Marinus,
    Thank you for reaching out to the Microsoft Fabric Forum Community.

     

    Please try the following DAX measure. I assume that your column contains additional text after the "-" character.

    CALCULATE(
        COUNTROWS('Overzicht aanvragen'),
        FILTER(
            'Overzicht aanvragen',
            NOT (
                LEFT('Overzicht aanvragen'[Aanvraag_Routelint], SEARCH(" -", 'Overzicht aanvragen'[Aanvraag_Routelint] & " -") - 1) 
                IN { "Zvg", "Vlgr", "Rsdg", "Odzg", "Edng", "Bdlg", "Svgg" }
            )
        )
    )

     

    If the issue persists, kindly share a sample dataset along with the expected output. This will help in better understanding the problem and finding an appropriate solution.

     

    If you find this information helpful, please consider "Accepting it as a solution" and giving it a "kudos" to assist other community members facing similar challenges.

     

    Thank you.

    • Marinus's avatar
      Marinus
      Helper I

      I have deleted the dashes to make it clearer.

      I have a command to countrows with a specific tekst :

      CALCULATE(
      COUNTROWS('Overzicht aanvragen'),
      'Overzicht aanvragen'[Aanvraag_Routelint] IN { "Zvg", "Vlgr", "Rsdg", "Odzg", "Edng", "Bdlg", "Svgg" }
      )

      This way i count only the rows with these texts in it, but now i want to count the rows without these specific texts in it.

      • v-ssriganesh's avatar
        v-ssriganesh
        Community Support

        Hi Marinus,

        Thanks for your update.

         

        I’ve reproduced your scenario using sample data matching your raw data structure and achieved the expected output. Create the fallowing dax measure to calculate countrows.

         

        rows = CALCULATE(
        COUNTROWS(
        FILTER(ALL('table'),
        NOT('table'[Aanvraag_Routelint] IN { "Zvg -", "Vlgr -", "Rsdg -", "Odzg -", "Edng -", "Bdlg -", "Svgg -" })
        )
        )
        )

        The .pbix file attached demonstrates this working solution with your sample data.

         

        If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
        Thank you.