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

Count of days based on filter for average

Hi, i am a newbie in power bi so pardon my ignorance 🙂

I have application wise traffic data since 24-Feb-2020 till 08-Apr-2020 (45 days). An application has sub application so for single day multiple rows per application is possible.

 

I just want to get daily average traffic of each application based on the selected days in filter. But i am unable to get the days count correctly.

 

I applied month filter for Apr, there are 8 dates data for April. It is possible that some application might have only 5 days data for April. So i want to return count of days per each application.

 

I used following formula, but it is returning me 45 for each application, though i've applied Apr filter.

 

Measure =
var start_Date=FIRSTDATE(ALLSELECTED('App'[Date]))
var end_Date=LASTDATE(ALLSELECTED('App'[Date]))
return
CALCULATE(DATEDIFF(start_Date, end_Date, DAY))
 
Capture.PNG
Capture2.PNG

 

 
 
 
Once i get the correct count of day, I will divide it with sum of traffic to get the average.
 
any help would be appreciated.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ghamiz 
The formula and relation has some problem

distinct date use
distinctcount('App'[Date])

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@ghamiz 
The formula and relation has some problem

distinct date use
distinctcount('App'[Date])

hey this really worked, how silly of me 😞

 

thanks for the help

🙂

Greg_Deckler
Super User
Super User

It looks like a relationship is not setup correctly. 

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.