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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Count IF Function

Dear All,

 

Please help in correct the below tabular function. I am getting wrong answers in my tabulation.

 

ENQ Item Count = COUNTROWS(FILTER(ALL('Monthly report'),'Monthly report'[Item]=EARLIER('Monthly report'[Item]) || 'Monthly report'[Quotation number]=EARLIER('Monthly report'[Quotation number])))
2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@Fowmy 

 

Through your guidance i got resolved my out come in tabulation. I have slightly modified your syntex as below. I am getting the desired results as expected with below syntex. 

 

Thanks for your kind support.

 

ENQ Item COUNT =
VAR enqitem =
MAX ( 'Monthly report'[Item] )-1
VAR quote =
( 'Monthly report'[Quotation number] )
RETURN
CALCULATE (
COUNTROWS ( 'Monthly report' ),
OR ( 'Monthly report'[Item] = enqitem, 'Monthly report'[Quotation number] = quote ),
REMOVEFILTERS ( 'Monthly report' )
)

View solution in original post

@Anonymous 

I believe you are creating a Calculated Column NOT a measure. If you are getting the expected results then, it should be fine. 


 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@Fowmy 

 

Thanks for your kind reply and suggession.

 

I tried with you suggessions and results found "11" in all the rows in my tabulation. 

 

Note, i have slightly modified your syntex due to error while running the same. Same was pasted in below for your review. Could you please check again and help me to resolve this.

 

ENQItemCOUNT =
VAR enqitem =
MAX ( 'Monthly report'[Item] )
VAR quote =
MAX ( 'Monthly report'[Quotation number] )
RETURN
CALCULATE (
COUNTROWS ( 'Monthly report' ),
OR ( 'Monthly report'[Item] = enqitem, 'Monthly report'[Quotation number] = quote ),
REMOVEFILTERS ( 'Monthly report' )
)
Fowmy
Super User
Super User

@Anonymous 

Not sure where and how you execute this measure. Please try:

ENQItemCOUNT =
VAR item =
    MAX ( 'Monthly report'[Item] )
VAR quote =
    MAX ( 'Monthly report'[Quotation number] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Monthly report' ),
        OR ( 'Monthly report'[Item] = item, 'Monthly report'[Quotation number] = quote ),
        REMOVEFILTERS ( 'Monthly report' )
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy 

 

Through your guidance i got resolved my out come in tabulation. I have slightly modified your syntex as below. I am getting the desired results as expected with below syntex. 

 

Thanks for your kind support.

 

ENQ Item COUNT =
VAR enqitem =
MAX ( 'Monthly report'[Item] )-1
VAR quote =
( 'Monthly report'[Quotation number] )
RETURN
CALCULATE (
COUNTROWS ( 'Monthly report' ),
OR ( 'Monthly report'[Item] = enqitem, 'Monthly report'[Quotation number] = quote ),
REMOVEFILTERS ( 'Monthly report' )
)
Anonymous
Not applicable

Hi @Anonymous ,

Could you please mark your post as Answered since you have gotten the desired result? It will help the others in the community find the solution easily if they face the similar problem with you. Thank you.

Best Regards

@Anonymous 

I believe you are creating a Calculated Column NOT a measure. If you are getting the expected results then, it should be fine. 


 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.