Forum Discussion
% Days Complete DAX
- 8 years ago
Hi Anonymous,
Please use the following formula.Measure = VAR Select_mon = SELECTEDVALUE ( Calendario[month] ) VAR Actual_mon = MONTH ( TODAY () ) RETURN SWITCH ( TRUE (), Actual_mon > Select_mon, 1, Actual_mon < Select_mon, 0, DIVIDE ( DAY ( TODAY () ), CALCULATE ( COUNTROWS ( 'Calendar' ), FILTER ( ALL ( 'Calendar' ), 'Calendar'[Year] = YEAR ( TODAY () ) && 'Calendar'[Month Number] = MONTH ( TODAY () ) ) ) ) )
Best Regards,
Angelia
Hi,
Thanks for your reply.
I already have a date table and a fact table, I would rather not create a second date table. Is it a way I can do this from the current date table?
something like this will work, assuming you have year and month number column in your calendar table
% Days = var totalDays = CALCULATE( COUNTROWS( 'Calendar' ), FILTER( ALL( 'Calendar' ), 'Calendar'[Year] = YEAR( TODAY() ) && 'Calendar'[Month Number] = MONTH( TODAY() ) ) ) var days = DAY( TODAY() ) RETURN DIVIDE( days, totalDays )
- Anonymous8 years agoNot applicable
Thanks for the reply!
This worked, but it only shows the percentage for the current month.
It doesn't change based on the month filter I put in.
Ex:
January 2018 Should be 100%
May 2018 should be 100%
July should be 61%
- parry2k8 years agoSuper User
Well in that case we need to change the dax, I just provided you based on the current date , just repace today() with selected date from the calendar in case a month/year is selected otherwise keep it today(), and rest of the logic will work.
- Anonymous8 years agoNot applicable
Perfect!
I get this error when attempting to change all date dimensions: