Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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:
Solved! Go to Solution.
Hi @GarlonYau
To count # of days per month
Days In Month = DAY(DATE(YEAR(T25[Date]),MONTH(T25[Date])+1,1)-1)
Cheers!
A
If you have a calendar table, a simply DISTINCTCOUNT can work.
Ex:
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)
How would I go about incorporating that into my existing equation?
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!
User | Count |
---|---|
84 | |
78 | |
70 | |
47 | |
41 |
User | Count |
---|---|
108 | |
53 | |
50 | |
40 | |
40 |