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
scyllanbay
Regular Visitor

How to count 2 items in a single row with multiple items listed

I have been spinnig my wheels trying to figure out the correct DAX formula to provide me with a total count of certain words in a single column.  Example:  I have a column for status with items such as "awarded", "not awarded", "pending award", "Lost", etc. etc.  I am looking for the correct way to tell the measure to count all of the awarded and not awarded in that same column.  Is that possible?  

1 ACCEPTED SOLUTION

@scyllanbay ,

 

See the file attached.

 

I didn't get how you calculated the Prediction column.

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

15 REPLIES 15
camargos88
Community Champion
Community Champion

Hi @scyllanbay ,

 

Try this measure:

_Count = CALCULATE(COUNTA('Table'[Column1]), FILTER('Table', 'Table'[Column1] IN {"awarded", "not awarded"}))
 
If you need a distinct count, just use:
_Count = CALCULATE(DISTINCTCOUNT('Table'[Column1]), FILTER('Table', 'Table'[Column1] IN {"awarded", "not awarded"}))


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



 I tried both of these and I am getting an error that says, "too many arguments were passed to the distinctcount function. the maximum argument count for the function is 1."  

See this example:

 

Capture.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



I got the formula to work and provide a 2... however, I need it to count all of the awarded and all of the not awarded and pull back that total number which may be 53.  Sorry, for the back and forth, I'm taking classes right now and learning but it's a tricky thing to learn. 

I changed it to counta and that worked.  Is there now a way to add another column in this formula to pull out another item such as "hard bid".  So, in the end it would be giving me the total count of all awarded and not awarded in column A and the total hard bid in column B.  To get a true number of hard bids that were awarded and not awarded?

@scyllanbay ,

 

You can use input the values here:

_Count = CALCULATE(COUNTA('Table'[Column1]), FILTER('Table', 'Table'[Column1] IN {"awarded", "not awarded", "OTHERS"}

and Column2 = "ABC"))

 

If you have a sample dataset I can help you with a pbix.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Is there a way to attached a csv file on here?  

@scyllanbay ,

 

You can use google drive / one drive for it, and share the link here.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



https://drive.google.com/file/d/1Z9SkhkZmm_635clOEL1uLFKKNo8890Sg/view?usp=sharing

 

I think that will work.  The first tab has my data and the second tab is what I am trying to create in Power BI.  Below is what I have so far, except the Total Hard Bid column is the one that I'm currently working on and it's 100% correct yet.   I have a lot of learning left to do and multiple classes on udemy already purchased 🙂

scyllanbay_0-1598537596843.png

 

@scyllanbay ,

 

I only see a csv file with Hard Bird and Negotiated, I believe there are 2 datasets here, right ?

 

Sorry I didn't get the connection with the first question. Can you explain it ?



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



https://drive.google.com/file/d/1Zm3hzluvTFGdv50wv4yvB6bZwMNnK8V8/view?usp=sharing

 

The one that you are seeing the the graph that I'm trying to produce in Power BI to look like the below.  The attached is the actual data set. 

 

scyllanbay_0-1598538484305.png

 

@scyllanbay ,

 

See the file attached.

 

I didn't get how you calculated the Prediction column.

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Honestly, I'm speechless. You have no idea how much I appreciate this and didn't expect you to pull all of that together, but Thank you!

 

He calculated the prdiction column by multiplying the percentage by pending.  


One more question, there is an "R" showing before all of the $ values.  Do you know why that is?

 

scyllanbay_0-1598541815472.png

 

@scyllanbay ,

 

That's because I've formatted this column as currency, I'm in Brazil that's why you are seeing this "R$"....

 

You can change it clicking here:

Capture.PNG

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thank you sooo much for helping me with this.  You have saved me so many hours of beating my head against my desk trying to figure this out.  

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.