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, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

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

@Anonymous 
The formula and relation has some problem

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

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous 
The formula and relation has some problem

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

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
Anonymous
Not applicable

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



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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