Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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