Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pandu473
Frequent Visitor

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 

1 ACCEPTED SOLUTION

HI @Pandu473,

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

7 REPLIES 7
Pandu473
Frequent Visitor

Hi 

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

Tahreem24
Super User
Super User

@Pandu473 Refer this screen shot also :

 

Capture.JPG

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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

 

Pandu473_0-1645443775295.png

 

@Pandu473 , 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
 
 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi 

I want distinct count of project id than rows

HI @Pandu473,

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Tahreem24
Super User
Super User

@Pandu473 ,Try this Measure:

Measure = CALCULATE(COUNTROWS(TableA),FILTER(TableA,TableA[Met]=TableA[Grand Total]))+0
 
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.