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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.