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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Count distinct R12

Spoiler
 

Hi, I have two col. Date and ID. I want for each date (day) make a distinct count for ID. R12. Twelve months back and rolling.

Plz help! 

 

Ex. data. 

DateIDCreate_measure (count(distinct ID last 12 month (R12) for each date)
2021-08-241018
2021-08-241028
2021-08-241038
2021-08-241018
2021-08-252018
2021-08-252018
2021-08-252028
2021-08-251018
2021-09-051018
2021-09-051028
2021-09-051068
2021-09-051078
2021-09-051088
 
7 REPLIES 7
Anonymous
Not applicable

Hi, Can someone plz help me find a solution @v-kelly-msft ? The file is uploaded. Thx! 🙂

v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

First create a related date table and create a relationship between the 2 tables;

Then create a measure as below:

Measure =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ID] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Date] <= MAX ( 'date table'[Date] )
            && 'Table'[Date] >= DATEADD ( 'date table'[Date], -12, MONTH )
    )
)

And you will see:

vkellymsft_0-1629962267061.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

Anonymous
Not applicable

Some screendump

mersson_0-1630673534101.pngmersson_1-1630673556122.pngmersson_2-1630673594425.png

 

Anonymous
Not applicable

Hi! Sorry.. i can't get it to work as i want. I have my pbix-file but i cant attach it to the meassage. Plz help

Hi  @Anonymous ,

 

Pls upload it to a cloud service then share a public link with us.

Remember to remove the confidential information.

 

Best Regards,
Kelly

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

Anonymous
Not applicable
amitchandak
Super User
Super User

@Anonymous , You have to create measures like these examples

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

 

or

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX(Sales[Sales Date]),-12,MONTH))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.