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
Clout
Helper III
Helper III

Counting how many times a row which is not blank appears within a certain period and create a ratio

Hello,

 

I want to create a DAX to check if the workers met the requiered count of measurements.

So they have to do for example one measurement per month and I want to check how many times they did the measurement within the month. After that I want to create a ratio between the total count of measurements and the requiered number of measurements. 

So when I put my filter from June to July, the count of measurements within the month is divided by 1. From June to November is divided by 6 and when I want to look at the whole year the count of measurements is divided by 12 and so on.

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Clout ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a date dimension table and create relationship with the fact table base on date field

2. Create a slicer base on the date field of Date table

3. Create a measure as below

Measure = 
VAR _mindate =
    MIN ( 'Date'[Date] )
VAR _maxdate =
    MAX ( 'Date'[Date] )
VAR _diffmonth =
    DATEDIFF ( _mindate, _maxdate, MONTH )
RETURN
    DIVIDE (
        CALCULATE ( DISTINCTCOUNT ( 'Table'[Measurement] ) ),
        IF ( _diffmonth <= 0, 1, _diffmonth )
    )

yingyinr_0-1617951489992.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Clout ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a date dimension table and create relationship with the fact table base on date field

2. Create a slicer base on the date field of Date table

3. Create a measure as below

Measure = 
VAR _mindate =
    MIN ( 'Date'[Date] )
VAR _maxdate =
    MAX ( 'Date'[Date] )
VAR _diffmonth =
    DATEDIFF ( _mindate, _maxdate, MONTH )
RETURN
    DIVIDE (
        CALCULATE ( DISTINCTCOUNT ( 'Table'[Measurement] ) ),
        IF ( _diffmonth <= 0, 1, _diffmonth )
    )

yingyinr_0-1617951489992.png

Best Regards

amitchandak
Super User
Super User

@Clout ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors