cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
p-ha Occasional Visitor
Occasional Visitor

Countif in Power BI

Hi all, I'm fairly new to Power BI and still trying to grasp the logic behind all the DAX and how to utilize them. Any help is greatly appreciated!

 

Here is my sample data table:

POItem #DescriptionLocationYearSupplier
100AA1Apple-GreenSTA0102017Supplier A
101AA2Apple-RedSTA0102018Supplier A
102BB1Banana-YellowSTA0102017Supplier B
103BB1Banana-YellowSTA0202018Supplier A
104BB2Banana-GreenSTA0302019Supplier C
105BB2Banana-GreenSTA0402017Supplier A
106BB3Banana-PinkSTA0302019Supplier B
107BB3Banana-PinkSTA0102017Supplier B
108CC1Candy-GreenSTA0102018Supplier A
109CC2Candy-RedSTA0102019Supplier A
110CC3Candy-YellowSTA0202018Supplier C
111CC4Candy-BlueSTA0302017Supplier B
112DD1Doll-GreenSTA0102019Supplier A
113DD1Doll-GreenSTA0302018Supplier B
114DD2Doll-BlueSTA0202017Supplier C
115DD2Doll-BlueSTA0402018Supplier C
116DD3Doll-RedSTA0102019Supplier A
117DD3Doll-RedSTA0402018Supplier B
118DD4Doll-PinkSTA0102017Supplier A
119DD4Doll-PinkSTA0302018Supplier A
120DD5Doll-YellowSTA0302019Supplier C
121DD5Doll-YellowSTA0202017Supplier A
122DD5Doll-YellowSTA0402019Supplier C

 

What I'm trying to achieve: (below is the result I got from Excel by running pivot table counting total PO per year per each item and countif on the side table)

 

My goal: 

- count/% of total item with transaction (PO) > 2 in each year and illustrate on canvas as the sum table (right) below.

 

 201720182019G. Total  item with transaction > 2   
AA11  1 20170   
AA2 1 1 20180   
BB111 2 20191   
BB21 12      
BB31 12      
CC1 1 1      
CC2  11      
CC3 1 1      
CC41  1      
DD1 112      
DD211 2      
DD3 112      
DD411 2      
DD51 23      
           

 

Thank you in advance for your help!

New.Bee.P.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

Re: Countif in Power BI

Hi p-ha,

 

According to your description, it seems that you want to get below result, right(if count(po)>1, then show 1 in Year)?

57.png

If so, you could use below measure to see whether it work or not

Measure 5 =
IF (
    CALCULATE (
        COUNT ( test[PO] ),
        FILTER (
            test,
            test[Item #] = MAX ( test[Item #] )
                && test[Year] = MAX ( test[Year] )
        )
    ) > 1,
    1,
    0
)

 

Best Regards,

Zoe Zhi

 

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

View solution in original post

Super User
Super User

Re: Countif in Power BI

Hi,

This measure works

Measure = COUNTROWS(FILTER(SUMMARIZE(VALUES(Data[Item #]),Data[Item #],"ABCD",COUNTROWS(Data)),[ABCD]>1))+0

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Countif in Power BI

Hi p-ha,

 

According to your description, it seems that you want to get below result, right(if count(po)>1, then show 1 in Year)?

57.png

If so, you could use below measure to see whether it work or not

Measure 5 =
IF (
    CALCULATE (
        COUNT ( test[PO] ),
        FILTER (
            test,
            test[Item #] = MAX ( test[Item #] )
                && test[Year] = MAX ( test[Year] )
        )
    ) > 1,
    1,
    0
)

 

Best Regards,

Zoe Zhi

 

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

View solution in original post

Super User
Super User

Re: Countif in Power BI

Hi,

This measure works

Measure = COUNTROWS(FILTER(SUMMARIZE(VALUES(Data[Item #]),Data[Item #],"ABCD",COUNTROWS(Data)),[ABCD]>1))+0

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)