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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
actzikas
Frequent Visitor

Get a count of leads for the current month

I would like to create a measure that only returns the number of leads created for the current month (Count of Lead[ID]) 

 

So far I have the following: 

 

Is Current Month Lead = CALCULATE(COUNT(Lead[ID]), Filter('Lead', MONTH('Lead'[CreatedDate] = Month(Today()))), FILTER('Lead', YEAR('Lead'[CreatedDate]= Year(Today()))))
 
But I get the following error: The syntax for 'Lead' is incorrect. (DAX(CALCULATE(COUNT(Lead[ID]), Filter('Lead', MONTH('Lead'[CreatedDate] = Month(Today()))), FILTER('Lead', YEAR('Lead'[CreatedDate]= Year(Today())))))).
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @actzikas ,

 

Please add '' at Lead[ID].

You can use FORMAT() function as well, please modify the formula as below.

Is Current Month Lead =
CALCULATE (
    COUNT ( 'Lead'[ID] ),
    FILTER (
        'Lead',
        FORMAT ( 'Lead'[CreatedDate], "YYYYMM" ) = FORMAT ( TODAY (), "YYYYMM" )
    )
)

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

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

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @actzikas ,

 

Have your problem be solved? Please consider accept the answer as a solution if it worked.

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
v-jayw-msft
Community Support
Community Support

Hi @actzikas ,

 

Please add '' at Lead[ID].

You can use FORMAT() function as well, please modify the formula as below.

Is Current Month Lead =
CALCULATE (
    COUNT ( 'Lead'[ID] ),
    FILTER (
        'Lead',
        FORMAT ( 'Lead'[CreatedDate], "YYYYMM" ) = FORMAT ( TODAY (), "YYYYMM" )
    )
)

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

Lead is coming in ' ' at two place then it should in ' at all place.

Month and year for created date are not closed properly

CALCULATE(COUNT('Lead'[ID]), Filter('Lead', MONTH('Lead'[CreatedDate]) = Month(Today())), FILTER('Lead', YEAR('Lead'[CreatedDate])= Year(Today())))

CALCULATE(COUNT('Lead'[ID]), Filter('Lead', MONTH('Lead'[CreatedDate]) = Month(Today()) && YEAR('Lead'[CreatedDate])= Year(Today())))

 

I would recommend, join your created date with a date table and you date table and date from date table instead of created date

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

 

 

HotChilli
Super User
Super User

I couldn't find any evidence for it but it looks like ->lead<- is a reserved keyword.

So try putting quotes round every mention of it, instead of just some.

Also the double filter can be combined I think, using &&

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.