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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.