Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count and Sum

Hi All, 

Consider below table as example 

 

Consider below table 

Project IDMetNot MetGrand TotalCondition = If (Met = Grand Total), 1,0)
10030-012 21
10077-035 51
10093-028 81
10098-019 91
1010-0142 421
10119-0113 131
10142-015 51
10162-015270
10310-027 71
10331-048 81
10352-042240
10376-0112 121
10379-025 51

 

I want to have a dax which will compare the Met with Grand Total and then if they both matches then it is 1 or else it is 0 

once it is done i want to count the ' 1' and then total as sum

In my data set there is month column as well which is connected to dim_date table and that i can take care once the mesure is bulit 

  • Anonymous's avatar
    Anonymous
    4 years ago

    HI Anonymous,

    You can try to use the following measure formulas if it suitable for your requirement:

    Measure =
    VAR summary =
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            [Project ID],
            "Met", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Met/NotMet] = "Met" ),
            "Total", COUNTROWS ( 'Table' )
        )
    RETURN
        COUNTROWS ( FILTER ( summary, [Met] = [Total] ) )

    Regards,

    Xiaoxin Sheng

7 Replies

  • Anonymous ,Try this Measure:

    Measure = CALCULATE(COUNTROWS(TableA),FILTER(TableA,TableA[Met]=TableA[Grand Total]))+0
     
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      My Data source looks like this and  i want to achieve the soultion like what you have mentioned 

       

       

      • Tahreem24's avatar
        Tahreem24
        Icon for Super User rankSuper User

        Anonymous , Try this steps:

        Step 1: First Create a Measure for Met and likewise for NotMet:

        Met Measure = Caluculate(COUNTROWS(TableName),FILTER(TableName,TableName[Met/NotMet Column]="Met")

         

        Step 2: Likewise create for NotMet. Measure.

         

        Step 3: Create Measure for Grand Total.

        Grand Total Measure= COUNTROWS(TableName)

         

        Step 4: Create a Measure like below:

        Measure = CALCULATE(COUNTROWS(TableName),FILTER(TableName,[Met Measure]=[Grand Tota Measure]))+0
         
         

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi 

    I have done pivot form the existing data source to get grand total. How to get that grand total in dax on powerBI