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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
domleps
Regular Visitor

DAX unique count 5 day rolling total

Hi there,

 

I need some help with this dax measure formula please

 

I have the data set table on the left hand side - showing continuous periods of time flagged by an instance_id

 

I need the DAX to calculate the field i've highlighed in yellow - which is basically a unique count of the instance ID on a rolling 5 DAY basis.

 

 

domleps_0-1627315662402.png

 

e.g. - the value of 3 found on date 16/01/2020 is found by looking up the unique ids in the data set between 12/01/2020 and 16/01/2020 (5 day period) - and finding that there are three unique ids (3, 4 and 5) - there are two 4s, but it ignores one due to unique count

 

Is someone able to help with this?

 

Many thanks

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

unique instance count 5 days rolling total : =
CALCULATE (
DISTINCTCOUNTNOBLANK ( Data[instance_id] ),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE ( 'Calendar'[Date] ), -5, DAY )
)

 

 

Link to the sample PBIX file 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
domleps
Regular Visitor

thanks @Jihwan_Kim  - i've accepted this as a solution for this question.

 

However, I am still having issues as I am not able to use a measure to complete this calculation - i need to use a calculated column and I also am not able to use a separate date column as you have outlined in your solution.

 

I've created another post with a different version of the question - if you are able to take a look:

 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/7-day-count-and-distinct-count-by-worker-in-a...

Jihwan_Kim
Super User
Super User

Picture1.png

 

unique instance count 5 days rolling total : =
CALCULATE (
DISTINCTCOUNTNOBLANK ( Data[instance_id] ),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE ( 'Calendar'[Date] ), -5, DAY )
)

 

 

Link to the sample PBIX file 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.