Forum Discussion

ianvalleser21's avatar
ianvalleser21
New Member
2 years ago

DAX FILTERING

Hi, I need help. I have two tables connected in via Power BI relationship. The first table acts as the main one and then the second table contains the survey details for each items. I am trying to count the numbers of the surveys that scored 1 from the column CSAT on the second table but it keeps giving me the count of the surveys from the first main column with the same name.

 

First Table: 

Name: Main Dashboard

Columns:

End of Week

Survey Type

Surveys

- count of 1 surveys is 33

 

Second Table:

Name: Survey Data

Columns:

End of Week

Survey Type 

Surveys

- count of 1 surveys is 20

 

The formula I used is this: 

=CALCULATE(COUNTROWS(FILTER((Survey Data),Survey Data[Surveys]=1)),Survey Data, Main Dashboard)

 

This keeps giving me a score of 33 instead of 20.

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ianvalleser21 ,

     

    Based on your description, it appears that there is a problem with the dax formula that is not returning the expected counts from the second table.
    You just need to filter the "Survey Data" table and here is the corrected formula:

    SurveyCount =
    CALCULATE (
        COUNTROWS ( 'Survey Data' ),
        FILTER ( 'Survey Data', 'Survey Data'[Surveys] = 1 )
    )


    Best Regards,
    Adamk Kong

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

    • ianvalleser21's avatar
      ianvalleser21
      New Member

      Thank you for the answer. However, whenever I do that it's giving me a weird set of numbers in the table like this one. 

       

      End of WeekSurvey Scoure Count
      1/6/202414,076
      12/30/202314,076
      12/23/202314,076
      12/16/202314,076
      12/9/202314,076
      12/2/202314,076
      11/25/202314,076
      11/18/202314,076
      11/11/202314,076
      11/4/202314,076
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi ianvalleser21 ,

         

        In your case, how are the table relationships constructed and can you provide some test data for me to troubleshoot.


        Best Regards,
        Adamk Kong

  • v-kongfan-msft The table is connected using a helper table with unique values inside the data modelling tab:

     

     

     

    Main Table/Table 1:

    Month NameEnd of WeekReporting DateProduct Family
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Windows Consumer
    December12/6/202312/1/2023Unspecified
    December12/6/202312/1/2023Unspecified
    December12/6/202312/1/2023Unspecified
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Windows Consumer
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Windows Consumer
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Windows Consumer
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Unspecified
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Microsoft 365 and Office
    December12/6/202312/1/2023Windows Consumer

     

    Table 2/Survey Table:

     

    Month NameEnd of WeekReporting DateProduct FamilySurvey Scores
    December12/9/202312/1/2023Microsoft 365 and Office5
    December12/9/202312/1/2023Microsoft 365 and Office5
    December12/9/202312/4/2023Microsoft 365 and Office1
    December12/9/202312/4/2023Microsoft 365 and Office1
    December12/9/202312/4/2023Microsoft 365 and Office5
    December12/9/202312/4/2023Microsoft 365 and Office5
    December12/9/202312/4/2023Microsoft 365 and Office5
    December12/9/202312/4/2023Windows Consumer5
    December12/9/202312/4/2023Microsoft 365 and Office5
    December12/9/202312/4/2023Microsoft 365 and Office5
    December12/9/202312/5/2023Microsoft 365 and Office1
    December12/9/202312/5/2023Microsoft 365 and Office1
    December12/9/202312/6/2023Windows Consumer1
    December12/9/202312/6/2023Microsoft 365 and Office4
    December12/9/202312/7/2023Unspecified1
    December12/9/202312/7/2023Microsoft 365 and Office4
    December12/9/202312/7/2023Microsoft 365 and Office5
    December12/9/202312/7/2023Microsoft 365 and Office5
    December12/9/202312/7/2023Microsoft 365 and Office5
    December12/9/202312/7/2023Microsoft 365 and Office5
    December12/9/202312/7/2023Microsoft 365 and Office5
    December12/9/202312/7/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Unspecified1
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Windows Consumer5
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Microsoft 365 and Office5
    December12/9/202312/8/2023Unspecified5
    December12/9/202312/9/2023Unspecified1
    December12/9/202312/9/2023Windows Consumer5
    December12/9/202312/9/2023Microsoft 365 and Office5
    December12/9/202312/9/2023Microsoft 365 and Office5
    December12/9/202312/9/2023Microsoft 365 and Office5
    December12/9/202312/9/2023Windows Consumer5

     

    Connectors:

    Month Name

    December

     

    End of Week
    12/9/2023
    12/16/2023
    12/23/2023
    12/30/2023

     

    Reporting Date
    12/1/2023
    12/2/2023
    12/3/2023
    12/4/2023
    12/5/2023
    12/6/2023
    12/7/2023
    12/8/2023
    12/9/2023
    12/10/2023

     

    Product Family
    Microsoft 365 and Office
    Windows Consumer
    Unspecified