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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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

 

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]))
)
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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.