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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power BI Count IF Like

I have a spreadsheet which gets updated weekly and then have a dashboard in PowerBI. I want to be able to Query coloum 3 for all names like DA_ and then count coloum 4 for enabled/disabled

 

Is this possible?

1 ACCEPTED SOLUTION

MeasureCount = CALCULATE(COUNTROWS(Like);FILTER(Like;LEFT(Like[SamAccount];3)="DA_" && Like[enable]="TRUE"))

 

Best Regards,
Miguel

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

19 REPLIES 19
ZunzunUOC
Resolver III
Resolver III

Hi @Anonymous , Could you share your origin data?

 

Thanks.

Anonymous
Not applicable

Capture.PNG

 

Thats what the excel is like?

Ok, you can create a calculated column like this:

 

enable = IF(LEFT(Like[SAMACCOUNT];3)="DA_";"TRUE";"FALSE")

I recognize what you mean with count.

 

Best Regards,
Miguel

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

Anonymous
Not applicable

Capture.PNGGetting the following error. Even if i change SAMACCOUNT in the query to Column3 it gives the same error?

"like" is your table name?

Anonymous
Not applicable

The table in this instance is called "test" but even that does not work?

Ok, I see two wrong things:

  1. Names. You must change my names for your names (table and columns).
  2. In your capture, your columns has no names. You must define the first row like a header.

 

Otherwise, I test the code and works fine. Give me your feedback and see it.

Anonymous
Not applicable

Ok so i have named the coloums and the table? and it is still the same error? could you show your example?

Capture.PNG

Could you change ";" per ","?

Anonymous
Not applicable

So that seems to of fixed the ; issue. However it doesn't seem to allow me to count the enabled accounts?

Capture.PNG

Have you create a calculated column?

Anonymous
Not applicable

Ok i see now it works. However, that is not what i was looking for? I wanted to be able to add a measure so i can show it on a dashboard. I want to be able to Count all accounts which start with DA_ and in the enabled coloum are True. so if there are 30 accounts and only 10 are enabled it will show 10 not 30.

Ok, try with this:

 

MeasureCount = CALCULATE(COUNTROWS(Like);FILTER(Like;Like[enable]="TRUE"))
Anonymous
Not applicable

But i only want to count it if it has DA_ in SamAccount?

Then, change the code to:

 

MeasureCount = CALCULATE(COUNTROWS(Like);FILTER(Like;LEFT(Like[SamAccount];3)="DA_"))
Anonymous
Not applicable

But that doesnt do both so i need to count the enabled accounts that match DA_?

MeasureCount = CALCULATE(COUNTROWS(Like);FILTER(Like;LEFT(Like[SamAccount];3)="DA_" && Like[enable]="TRUE"))

 

Best Regards,
Miguel

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

Anonymous
Not applicable

Thank you 🙂 

@Anonymous 

 

By the way, you may help accept the solution above. Your contribution is highly appreciated.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.