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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Calculate days only for months that have applications

Hello,
I have two tables, one fact_table that contains the application_id and created_on (which is the date when the application was created) and one date_table(dimdate). I want to calculate the average of applications for the selected period. 
Avg = (nr of applications)/ (nr of days)
If I select period from March-July , I want the nr of days to be 62 for only the two months that have applications. 

application_idcreated_on
id105.03.2021
id201.07.2021
id310.07.2021
id412.07.2021
id520.07.2021
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you so much
I added the column Month-Year from the Created_on date and than used it. 

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Very easy one,

CNENFRNL_1-1646727727605.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Thank you so much
I added the column Month-Year from the Created_on date and than used it. 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

The slicer in my sample functions as, 

- even the startdate / enddate is in the middle of a certain month, it calculates from the beginning date of the month until the end date of the month.

 

Picture1.png

 

Average measure: =
VAR selectedyears =
    VALUES ( Dates[Year] )
VAR selectedmonths =
    VALUES ( Dates[Month] )
VAR selectedperiod_in_date =
    SUMMARIZE (
        FILTER (
            ALL ( Dates ),
            Dates[Year]
                IN selectedyears
                && Dates[Month] IN selectedmonths
        ),
        Dates[Date]
    )
VAR numberofapplications =
    CALCULATE ( COUNTROWS ( 'Fact' ), 'Fact'[created_on] IN selectedperiod_in_date )
VAR selectedapplication_in_year =
    SUMMARIZE (
        ADDCOLUMNS (
            CALCULATETABLE (
                VALUES ( 'Fact'[created_on] ),
                'Fact'[created_on] IN selectedperiod_in_date
            ),
            "@year", YEAR ( 'Fact'[created_on] )
        ),
        [@year]
    )
VAR selectedapplication_in_month =
    SUMMARIZE (
        ADDCOLUMNS (
            CALCULATETABLE (
                VALUES ( 'Fact'[created_on] ),
                'Fact'[created_on] IN selectedperiod_in_date
            ),
            "@month", MONTH ( 'Fact'[created_on] )
        ),
        [@month]
    )
VAR countdays =
    CALCULATE (
        COUNTROWS ( Dates ),
        FILTER (
            ALL ( Dates ),
            Dates[Year]
                IN selectedapplication_in_year
                && Dates[Month] IN selectedapplication_in_month
        )
    )
RETURN
    numberofapplications / countdays

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
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
Top Kudoed Authors