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
sharpedogs
Advocate II
Advocate II

DAX to calculate the 7 days and last 14 days activity.

Hi, 

I can do this easily using the the filter, but I really want to do it using DAX.

I've tried multiple "lastdate" variations but i'm not sure the syntext to move it back 7 or 14 days. 

 

I have a the below table and i simply want a DAX that counts the number of devices that last log on in the past 7 days. i'll replacate that formular to then account for the last 14 days. 

 

Device Name

Last Logon DateConfidence Level 
AAAJan 29Medium
BBBJan 3High 
CCApril 21Medium

 

2 ACCEPTED SOLUTIONS
az38
Community Champion
Community Champion

Hi @sharpedogs 

try

Measure = CALCULATE(COUNTROWS('Table');'Table'[Last Logon Date]>=today()-7)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

az38
Community Champion
Community Champion

@sharpedogs 

try

Measure = CALCULATE(COUNTROWS('Table');'Table'[Last Logon Date]>=today()-14;'Table'[Last Logon Date]<=today()-7)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

6 REPLIES 6
az38
Community Champion
Community Champion

Hi @sharpedogs 

try

Measure = CALCULATE(COUNTROWS('Table');'Table'[Last Logon Date]>=today()-7)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi, wondering if i can piggyback on my ask 🙂

 

Instead of the last 7 days... what if i now wanted a range say between 7 and 14 days? I'm not sure what i do with the TODAY () function so that is starts at 7 days?

 

 
az38
Community Champion
Community Champion

@sharpedogs 

try

Measure = CALCULATE(COUNTROWS('Table');'Table'[Last Logon Date]>=today()-14;'Table'[Last Logon Date]<=today()-7)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Why is it so simply when you provide the answer....lol

 

Thanks

 

 

az38
Community Champion
Community Champion

@sharpedogs 

it's a practice question.

good luck and welcome to power bi! 🙂


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Tried.... and worked perfectly!!!

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.

Top Solution Authors