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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
GarlonYau
Helper I
Helper I

Number of days in the period

Hi Folks,

 

I'm trying to create a measure based on this mathematical formula:

Measure = (Total Accounts Recievable in the Month * # of days in the given month) / Total Sales in the Month.

 

What I have so far: 

DIVIDE( SUM('BalanceSheet'[Accounts Receivable]) * XXXXX, SUM('IncomeStatement'[Sales]),0)
 
What I am struggling with is filling out what should go in the XXXXX portion. This would be a DAX formula for the number of days in the month (or in the time period - if it's going to respond drilling up and down in a visual)
 
Example:
Feburary = (Total Accounts Recievable in the Month * 28) / Total Sales in the Month.
March = (Total Accounts Recievable in the Month * 31) / Total Sales in the Month.
Q1  = (Total Accounts Recievable in the Month * 90) / Total Sales in the Month.
 
Thanks in advance for your help!
 
Cheers
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GarlonYau 

To count # of days per month

Days In Month = 
 DAY(DATE(YEAR(T25[Date]),MONTH(T25[Date])+1,1)-1)

Cheers!
A

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

If you have a calendar table, a simply DISTINCTCOUNT can work.

 

Ex:

Calendar - Count Days = DISTINCTCOUNT('Calendar'[Date])
Anonymous
Not applicable

Days in quarter -->

Add a column to your date table.

Days in Q = 
VAR FirstDateVisible =
    CALCULATE ( MIN ( 'Date'[Date] ) )
VAR FirstYearVisible =
    YEAR ( FirstDateVisible )
VAR FirstQuarterVisible =
    QUOTIENT ( MONTH ( FirstDateVisible ) - 1, 3 )
VAR DaysInQuarter =
    FILTER (
        ALL ( 'Date'[Date] ),
        YEAR ( 'Date'[Date] ) = FirstYearVisible
            && QUOTIENT ( MONTH ( 'Date'[Date] ) - 1, 3 ) = FirstQuarterVisible
    )
VAR FirstDayInQuarter =
    MINX (
        DaysInQuarter,
        'Date'[Date]
    )
VAR _Begin =
    CALCULATETABLE (
        VALUES ( 'Date'[Date] ),
        'Date'[Date] = FirstDayInQuarter
    )

VAR LastDateVisible =
    CALCULATE ( MAX ( 'Date'[Date] ) )
VAR LastYearVisible =
    YEAR ( LastDateVisible )
VAR LastQuarterVisible =
    QUOTIENT ( MONTH ( LastDateVisible ) - 1, 3 )

VAR LastDayInQuarter =
    MAXX (
        DaysInQuarter,
        'Date'[Date]
    )
VAR _End =
    CALCULATETABLE (
        VALUES ( 'Date'[Date] ),
        'Date'[Date] = LastDayInQuarter
    )

RETURN
DATEDIFF(_Begin,_End,DAY)
amitchandak
Super User
Super User

try, this is for line level

 

 

calculate((sum(Sales[Sales Amount])*DISTINCTCOUNT(Sales[Sales Date]))
)

distinct dates, if data is continuous

 

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

How would I go about incorporating that into my existing equation?

something like that

calculate(divide((SUM('BalanceSheet'[Accounts Receivable])*DISTINCTCOUNT(BalanceSheet[ Date])),SUM('IncomeStatement'[Sales]))
)
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
Anonymous
Not applicable

Hi @GarlonYau 

To count # of days per month

Days In Month = 
 DAY(DATE(YEAR(T25[Date]),MONTH(T25[Date])+1,1)-1)

Cheers!
A

@Anonymous 

I ended up getting it by using your new column!

Thank you so much!

 

Days Sales Outstanding = DIVIDE(SUM('Financial Statements - BALANCE SHEET'[(Group) Accounts Receivable])*AVERAGE('Date'[Days In Month]), SUM('Financial Statements - INCOME STATEMENT'[(Subgroup) Sales]),0)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.