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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
freemainia
Helper I
Helper I

COUNTIF measure

Hi,

 

I would like to:

1. Count the number of IDs that have a "Yes" in any of the corresponding Train cells (answer = 2)

2. Count the number of IDs that don't have a "Yes", but do have a "Partial", in any of the corresponding Train cells (answer = 2)

3. Count the number of IDs that have a "No" in all of the corresponding Train cells (answer = 1)

 

Project 1Project 2Project 3What I want
IDTrain
1Yes
2No
3No
4Partial
5No

 

IDTrain
1 No
2 No
3 Partial
4 No
5Partial

 

IDTrain
1 No
2 No
3 No
4 Yes
5Partial

 

IDTrain
1 Yes
2 No
3 Partial
4 Yes
5Partial

 

 

I would like this to be a measure (rather than a column) as sometimes I may filter to one project, two projects, or all three projects.

 

Cheers.

 

 

 

 

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Do you have each Project's data in a seperat table?


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

Currently, they are in separate tables.

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

Many thanks @Ashish_Mathur.

Seems to be working now, with the slight adjustment of changing:

 
Measure 3 = COUNTROWS(FILTER(VALUES(Data[ID]),[No count]=3))


to

Measure 3 = COUNTROWS(FILTER(VALUES(Data[ID]),[No count trains]=DISTINCTCOUNT(Data[Project])))
 
Having the value of "3" didn't work when less than 3 projects were selected. I think (hope) the addition of DISTINCTCOUNT(Data[Project]) controls for the number of projects selected.

You are welcome.


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

@freemainia , For the last columns in the power query a new column

Make sure the two header are merged in date

 

let 

_a = {[Project 1 Train], [Project 2 Train],[Project 3 Train]}

_b = if List.Contains(_a, "Yes") then "Yes" else if List.Contains(_a, "Partial") "Partial" else "No"

in

_b

 

Or New column in dax

 

var _a = {[Project 1 Train], [Project 2 Train],[Project 3 Train]}

_b = Switch(true(),
Containsstring(_a, "Yes") , "Yes",
Containsstring(_a, "Partial") , "Partial" ,
"No")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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