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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Need to add the count from the condition

Hello Power BI community,

 

I have the data in the following format.

 

Products                     Inv Days

A                                    39

B                                    101

C                                    55

D                                    40

E                                     60

F                                    30

 

I want to create 3 cards. 

 

1) count when inv. days<=40

2) count when inv. days >40 and <=60

3) count when inv. days > 60

 

I tried

 

low inv = IF(Table[inv. days] <41,1,0) and then in a card, I would add the sum of the low inv. but it is giving me the count of total rows instead.

 

Help will be appreciated.

 

2 ACCEPTED SOLUTIONS

@Anonymous I think @amitchandak  means COUNTX not SUMX

 

countx(filter(summarize(Table,Table[Products],"_1",[Inv Days]),[_1]<=40),[Products])


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

As discussed use a common dimension.

Countx(filter(summarize(Table,Products[Products],"_1",[Inv Days]),[_1]<=40),[Products])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

9 REPLIES 9
amitchandak
Super User
Super User

@VatsalRaval

You can try how

calculate(count(Table[Products]), Tabla[Inv Days]<-40)

calculate(count(Table[Products]), Table[Inv Days]>-40 && Table[Inv Days]<-60)
calculate(count(Table[Products]), Tabla[Inv Days]>-60)

Or just create a count measure and use the visual level filter

count(Table[Products])

https://docs.microsoft.com/en-us/power-bi/power-bi-report-filter

You can also use distinctcount,if necessary, instead of counting

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@VatsalRaval

You can try how

calculate(count(Table[Products]), Tabla[Inv Days]<-40)

calculate(count(Table[Products]), Table[Inv Days]>-40 && Table[Inv Days]<-60)
calculate(count(Table[Products]), Tabla[Inv Days]>-60)

Or just create a count measure and use the visual level filter

count(Table[Products])

https://docs.microsoft.com/en-us/power-bi/power-bi-report-filter

You can also use distinctcount,if necessary, instead of counting

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Thanks for the response. I am getting the following error.

 

A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

@Anonymous , You may have try like

 

calculate(count(Table[Products]),filter(Table, Table[Inv Days]<=40))

calculate(count(Table[Products]),filter(Table, Table[Inv Days]>=40 && Table[Inv Days]<=60))
calculate(count(Table[Products]),filter(Table, Table[Inv Days]>=60))

 

May be values or summarize too

calculate(countX(values(Table[Products]),Table[Products]),filter(Table, Table[Inv Days]<=40))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Anonymous 

Other than what I have given in the last update, if Inv Days is a measure , you may have to change all of them like this

 

sumx(filter(summarize(Table,Table[Products],"_1",[Inv Days]),[_1]<=40),[Products])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

 

For the last comment, I am getting this error. 

 

"Function SumX can not work with value type "string".

As discussed use a common dimension.

Countx(filter(summarize(Table,Products[Products],"_1",[Inv Days]),[_1]<=40),[Products])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Anonymous I think @amitchandak  means COUNTX not SUMX

 

countx(filter(summarize(Table,Table[Products],"_1",[Inv Days]),[_1]<=40),[Products])


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Yes, inv day is a measure. Probably that is why it wasn't moving forward. Let me try this.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors