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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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