Forum Discussion
Cumulative Value based on condition
- Anonymous1 year ago
Hi, eryka_90
You can try the following dax to achieve your need.Measure:
Net Due = VAR _netDue = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', MONTH ( 'Table'[Net Due Date] ) - 1 = MONTH ( SELECTEDVALUE ( 'Date'[firstDayofMonth] ) ) ) ) RETURN _netDue 0-15 = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[DaysDiff_1] <= 15 && MONTH ( 'Table'[Net Due Date] ) = MONTH ( SELECTEDVALUE ( 'Date'[firstDayofMonth] ) ) ) ) 16-31 = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[DaysDiff_1] < 31 && 'Table'[DaysDiff_1] > 16 && MONTH ( 'Table'[Net Due Date] ) = MONTH ( SELECTEDVALUE ( 'Date'[firstDayofMonth] ) ) ) ) DaysDiff_1 = VAR _netDueDate = SELECTEDVALUE ( 'Table'[Net Due Date] ) VAR _lastDayofMonth = EOMONTH ( _netDueDate, 0 ) VAR _dayDiff = INT ( _lastDayofMonth - _netDueDate ) RETURN _dayDiff DaysDiff_2 = VAR _netDueDate = SELECTEDVALUE ( 'Table'[Net Due Date] ) VAR _lastDayofMonth = EOMONTH ( _netDueDate, 1 ) VAR _dayDiff = INT ( _lastDayofMonth - _netDueDate ) RETURN _dayDiffBest Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi, eryka_90
You can try the following dax to achieve your need.
Measure:
Net Due =
VAR _netDue =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
MONTH ( 'Table'[Net Due Date] ) - 1
= MONTH ( SELECTEDVALUE ( 'Date'[firstDayofMonth] ) )
)
)
RETURN
_netDue
0-15 =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[DaysDiff_1] <= 15
&& MONTH ( 'Table'[Net Due Date] )
= MONTH ( SELECTEDVALUE ( 'Date'[firstDayofMonth] ) )
)
)
16-31 =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[DaysDiff_1] < 31
&& 'Table'[DaysDiff_1] > 16
&& MONTH ( 'Table'[Net Due Date] )
= MONTH ( SELECTEDVALUE ( 'Date'[firstDayofMonth] ) )
)
)
DaysDiff_1 =
VAR _netDueDate =
SELECTEDVALUE ( 'Table'[Net Due Date] )
VAR _lastDayofMonth =
EOMONTH ( _netDueDate, 0 )
VAR _dayDiff =
INT ( _lastDayofMonth - _netDueDate )
RETURN
_dayDiff
DaysDiff_2 =
VAR _netDueDate =
SELECTEDVALUE ( 'Table'[Net Due Date] )
VAR _lastDayofMonth =
EOMONTH ( _netDueDate, 1 )
VAR _dayDiff =
INT ( _lastDayofMonth - _netDueDate )
RETURN
_dayDiff
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum