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
mbryant2014
Frequent Visitor

Count Data based on Filter

Hello - I'm sure this is simple but I'm stumped.  Below is some sample data:

 

Agent IDCust IDSale
113/1/2020
123/2/2020
133/3/2020
143/3/2020
153/4/2020
163/5/2020
173/5/2020
183/5/2020
193/6/2020
1103/7/2020
1113/8/2020
1123/9/2020
1133/10/2020

 

Assume I have this table also linked to a dimCalendar table where the Sale Date is linked to a Date field.  I have a slicer using the dimCalendar Date table.  I want to be able to count the number of Sales dates based on the Date filter visual that I'm using.  How can I make this happen?

 

Thanks!

 

6 REPLIES 6
mbryant2014
Frequent Visitor

Thank you for the replies.  I don't think I gave a good explanation of the issue.  I'll try and give a better explanation with some expanded data.  I have 2 tables, a readings table and a date table.  The date table is simply a list of dates.  The readings table has all of the pertinent date.  I have the 2 tables joined via the readingDate field.  I have a slicer visual that is using the Date field in the date table.  What I want to do is to count all of the Second Sale rows that fall within the slicer selection.  So based on the below data, if the slicer is set to 3/5/20-3/9/30 - I'd expect to see 3 retuned on a card visual.  Is this possible?  I tried the solutions presented and they don't seeme to working as I imagined.  Thanks!

 

One side note - the second sale field is actually a related measure that is coming from a customer table joined to the readings table via the customerid.

 

SiteNameCustomeridreadingDateReadingDateTimeReadingIDSecond Sale
AA1496733/6/20203/6/2020 17:1311734772 
AA1935453/6/20203/6/2020 15:3511734502 
AA1935453/6/20203/6/2020 16:0611734544 
AA1935453/7/20203/7/2020 14:3511737585 
AA1935453/7/20203/7/2020 14:5611737625 
AA1935453/7/20203/7/2020 15:0711737663 
AA1935453/8/20203/8/2020 6:5211739291 
AA1935453/9/20203/9/2020 15:5611744023 
AA1935453/9/20203/9/2020 16:1611744066 
AA2326893/4/20203/4/2020 15:1311727001 
AA2326893/9/20203/9/2020 16:2911744084 
AA3903293/6/20203/6/2020 17:3811734881 
AA4079953/1/20203/1/2020 15:2711717027 
AA4534253/6/20203/6/2020 15:0111734365 
AA5401173/7/20203/7/2020 17:0511737977 
AA5462093/7/20203/7/2020 17:2411738028 
AA5462093/7/20203/7/2020 17:3511738063 
AA5639883/4/20203/4/2020 16:1811727197 
AA5749943/7/20203/7/2020 3:5311736090 
AA5749943/7/20203/7/2020 4:0611736104 
AA6023183/7/20203/7/2020 7:2911736408 
AA6205953/9/20203/9/2020 16:5211744188 
AA6272023/4/20203/4/2020 15:0011726909 
AA6712953/7/20203/7/2020 7:2011736377 
AA6957423/8/20203/8/2020 4:2111739142 
AA7969933/7/20203/7/2020 6:3411736292 
AA8082903/6/20203/6/2020 16:2511734614 
AA8746973/7/20203/7/2020 15:52117377846/14/2018
AA8794673/8/20203/8/2020 6:21117392357/12/2018
AA9081303/8/20203/8/2020 4:441173916211/30/2018
AA9396663/7/20203/7/2020 6:08117362653/23/2019
AA9550623/7/20203/7/2020 15:20117376986/16/2019
AA9932193/8/20203/8/2020 7:28117393447/31/2018
AA10192153/7/20203/7/2020 5:31117361922/20/2020
AA10204113/7/20203/7/2020 3:34117360722/18/2020
AA10213453/7/20203/7/2020 4:30117361322/20/2020
AA10216813/7/20203/7/2020 16:36117379103/6/2020
AA10265833/8/20203/8/2020 6:01117392033/9/2020
AA10265913/8/20203/8/2020 7:12117393263/9/2020
AA10271543/9/20203/9/2020 16:40117441403/10/2020

 

Hi @mbryant2014

 

You need a measure as below:

 

 

Measure = 
IF(SELECTEDVALUE('Table'[Second Sale]) in VALUES('Table 2'[Date]),SELECTEDVALUE('Table'[Second Sale]),BLANK())

 

 

Finally you will see:

 

Annotation 2020-03-17 104046.png

 

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

 

 

Hi Kelly - thanks!

 

One more question - how can I get this into a Card visual with a count of the returned values.  In your example, I'd like to use a card visual displaying 3.  Make sense?

 

thanks!

v-kelly-msft
Community Support
Community Support

Hi @mbryant2014

 

Drag  column Sales of  the table to a card visual, right click the field and choose" count":

Annotation 2020-03-12 140631.png

Or you can create a measure as below:

 

measure = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('table 2','table 2'[Date]))

 

Then put the calendar date to a slicer :

Annotation 2020-03-12 140851.png

Finally you can fulfill what you need.

 

Here is the related .pbix file.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
amitchandak
Super User
Super User

@mbryant2014 

If you date is connected to Date calendar you put that on any visual any of the fields from the sales table and change aggregation on the fly by right click on the field in the visualization pane

 

Or create like

Cnt = count(table[Cust Id])

Dis Cnt = distinctcount(table[Cust Id])

 

 

Cnt = count(table[AgentId])

Dis Cnt = distinctcount(table[Agent Id])

 

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/

HotChilli
Super User
Super User

Pull the Sale on to a card. Change the aggregation in the Values well to Count.

OR

Create a measure like CountSale = COUNT(TableX[Sale])  and drag that on to a card

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.