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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to Count (qty of leads) daily?

Hi there,

 

I'm trying to calculate how many leads are being created on a daily basis.

 

On the table view_leads a created a column called DAY/DATE with the following formula: DAY/DATE = FORMAT(view_leads[create_timestamp],"DD/MMM/YYYY")

 

I have a second table where I'm summarizing all the calculations and there I created a column called Qty of Leads with the following formula:  Qty of Leads = CALCULATE(COUNT(view_leads[id]),ALLEXCEPT(view_leads, view_leads[DAY/DATE]))

 

The result is that is that the calculation is returning the Year to Date counting on every day/date.

 

Any ideas on how to fix it?

 

pb1.png

 

 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this:

Qty of Leads =
CALCULATE (
    COUNT ( view_leads[id] ),
    FILTER ( view_leads, view_leads[Day/Date] = [Date] )
)

 

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

Appreciate your Kudos!!

 

View solution in original post

9 REPLIES 9
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this:

Qty of Leads =
CALCULATE (
    COUNT ( view_leads[id] ),
    FILTER ( view_leads, view_leads[Day/Date] = [Date] )
)

 

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

Appreciate your Kudos!!

 

Anonymous
Not applicable

I edited the format and now it has worked. Is there any way to replace the blank values to zero in that formula?

Thanks again!

HI @Anonymous 

 

Try this:

Qty of Leads =
Var _C =
CALCULATE (
    COUNT ( view_leads[id] ),
    FILTER ( view_leads, view_leads[Day/Date] = [Date] )
)
return
if(isblank(_C),0,_C)

 

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

Appreciate your Kudos!!

 

Anonymous
Not applicable

It didn't work, it returns an error message: DAX comparison operations do not support comparing values of type Text with values of type Date. Consider using the VALUE or FORMAT function to convert one of the values.

samdthompson
Memorable Member
Memorable Member

Ok, its the relationship from the view_leads back to the Y Total Calculations path. Its not going to work like that. You really need to connect the DateDimension table direct to the view leads. rather than via that Month Table. its not going to work otherwise. *:1 Month:Date and 1:* Month:Leasds. The solution after fixing the relationships is just make a measure in the view_leads table:

 

_Qty of Leads = CALCULATE(COUNTDISTINCT(view_leads[id]),ALLEXCEPT(DateDimension, DateDimension[DAY/DATE]))

 

 

// if this is a solution please mark as such. Kudos always appreciated.
Anonymous
Not applicable

When I changed the relationship it messed with my visuals in other tab. Do you believe I can do that in other table?

Anonymous
Not applicable

That's the problem, I need to create that count in the table Y Total Calculations. I'm wondering if I mess with the relationship, other visuals may be affected too. 

samdthompson
Memorable Member
Memorable Member

Hi, can you share a picture of the relationship diagram. I suspect its becasue you are making the calculated column on the date table and there will be a oneway relationship from the date table to the fact table.

 

You could try to make this same calculated column on the fact table with:

 

Qty of Leads = CALCULATE(COUNTDISTINCT(view_leads[id]),ALLEXCEPT(calendar, calendar[DAY/DATE]))

 

 

 

 

// if this is a solution please mark as such. Kudos always appreciated.
Anonymous
Not applicable

There you go. It's a 1to1 relationship. 

 

pb1.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.