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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
georgec96
Helper II
Helper II

Count rows where date column is 1st day of next month

Hi all, im trying to create a measure that would count all rows where the column date is 1st day of next month however im getting an error when using the CALCULATE function.

 

"A function "CALCULATE" has been used in a true or false expression that is used as a table filter expression. This is not allowed."

 

Thank you in advance

12 REPLIES 12
v-xiaotang
Community Support
Community Support

Hi @georgec96 

Thanks for reaching out to us.

I just want to confirm if you resolved this issue? If yes, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.

If you need more help, please let me know.

 

Best Regards,

Community Support Team _Tang

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

tamerj1
Super User
Super User

Hi @georgec96 

please try

 

 

DK orders Left =
VAR NextMonth =
    EOMONTH ( ebs_lcl_open_lines[order_due_date], 0 ) + 1
RETURN
    CALCULATE (
        COUNT ( ebs_lcl_open_orders[oracle_order_number] ),
        ebs_lcl_open_orders[due_date] = NextMonth
    )

 

 

Hi @tamerj1 

 

Can I write this as a measure?

 

It won't let me reference the datecolumn when i try.

georgec96_0-1655976630151.png

 

@georgec96 
Yes you can

DK orders Left =
VAR NextMonth =
    EOMONTH ( MAX ( ebs_lcl_open_lines[order_due_date] ), 0 ) + 1
RETURN
    CALCULATE (
        COUNT ( ebs_lcl_open_orders[oracle_order_number] ),
        ebs_lcl_open_orders[due_date] = NextMonth
    )

Hi @tamerj1 , thanks for your reply

 

However my measure is returning a blank value

 

georgec96_1-1655979567873.png

 

@georgec96 

Yes as there is no data for next month. You need to slice by or select date

@tamerj1 

 

column due_date containts the date 1st of july 2022 which is what I want to count.

 

I was hoping that the measure will return a count of all those rows where the due_date is 1st of july 2022

@georgec96 

Ok then let's return nextmonth 

DK orders Left =
VAR NextMonth =
    EOMONTH ( MAX ( ebs_lcl_open_lines[order_due_date] ), 0 ) + 1
VAR Result =
    CALCULATE (
        COUNT ( ebs_lcl_open_orders[oracle_order_number] ),
        ebs_lcl_open_orders[due_date] = NextMonth
    )
RETURN
    NextMonth

@georgec96 
How does your data look like?

tamerj1
Super User
Super User

@Hi @georgec96 

what code did you use?

@tamerj1 

 

georgec96_0-1655979745429.png

 

Hi @tamerj1  I have used the following formula 

 

DK orders Left = CALCULATE(COUNT(ebs_lcl_open_orders[oracle_order_number]),ebs_lcl_open_orders[due_date]=NEXTMONTH(ebs_lcl_open_lines[order_due_date]))

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors