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
athomp15
Helper I
Helper I

Help with DAX filter

Hi All,

 

Would really appreciate some help on a DAX formula.  I am calculating the number of hits users have to a URLs within a 7 day rolling period.  The measure looks like this.

 

Rolling 7 Day File Views =
CALCULATE (
SUM(AuditDataTable[Views],
FILTER (
ALL (AuditDataTable[CreationDate]),
AuditDataTable[CreationDate]
>= MAX ( AuditDataTable[CreationDate]) - 7
&& AuditDataTable[CreationDate] <= MAX ( AuditDataTable[CreationDate])
)
)

 

The measure works fine.  However I am now trying to work out what I need to change to provide number of users (email address) where they have exceeded 20 View on a distinct count of the URL.  I can get some output using the following measure, but as soon as I change SUM(AuditDataTable[Views] to DISTINCT(DataTable[Url]) in the  returns blank.

 

Threshold Alerts = CALCULATE(COUNTROWS(AuditDataTable), FILTER(AuditDataTable,[Rolling 7 Day File Views] > 20))

 

 

Many thanks

Alex

 

 

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @athomp15,

 

Try to make the DISTINCTCOUNT(DataTable[Url]).

 

When you use DISTINCT you are returning the values that are distinct in a column so this is a mutiple value measure and will not return what your need, DISTINCTCOUNT will count as the name says.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Hi @athomp15,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @athomp15,

 

Based on your description, I made a sample here and update your formula as below, then your second formula can work well.

 

Rolling 7 Day File Views = 
CALCULATE (
SUM(AuditDataTable[Views]),
FILTER (
ALL(AuditDataTable),
AuditDataTable[CreationDate]
>= MAX ( AuditDataTable[CreationDate]) - 7
&& AuditDataTable[CreationDate] <= MAX ( AuditDataTable[CreationDate])
)
)

Capture.PNG

 

For more details, please check the pbix as attached. If it doesn't meet your requirement, kindly share your pbix to me.

 

https://www.dropbox.com/s/qsuujobu8wx0pzp/DAX%20FIL.pbix?dl=0

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @athomp15,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
MFelix
Super User
Super User

Hi @athomp15,

 

Try to make the DISTINCTCOUNT(DataTable[Url]).

 

When you use DISTINCT you are returning the values that are distinct in a column so this is a mutiple value measure and will not return what your need, DISTINCTCOUNT will count as the name says.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.