Forum Discussion
Create simple DAX Measure
- Anonymous1 year ago
Hi arunh100
Please try the following possible solution:
YTDMeasure = VAR MaxMonthYear = CALCULATE(MAXX(ALL('Exceptions'), 'Exceptions'[CreatedMthYr])) VAR CurrentMonthYear = SELECTEDVALUE('Exceptions'[CreatedMthYr]) VAR CurrentMonth = MOD(VALUE(CurrentMonthYear), 100) VAR CurrentYear = INT(DIVIDE(VALUE(CurrentMonthYear), 100, 0)) VAR PreviousMonthYear = IF( CurrentMonth = 1, (CurrentYear - 1) * 100 + 12, CurrentYear * 100 + (CurrentMonth - 1) ) VAR CurrentMonthExceptions = CALCULATE( COUNT(Exceptions[Task ID]), 'Exceptions'[CreatedMthYr] = CurrentMonthYear ) VAR PreviousMonthExceptions = CALCULATE( COUNT(Exceptions[Task ID]), 'Exceptions'[CreatedMthYr] = PreviousMonthYear ) VAR PreviousMonthExceptionsWithZero = IF( ISBLANK(PreviousMonthExceptions), 0, PreviousMonthExceptions ) VAR YTDExceptions = IF( CurrentMonthYear = MaxMonthYear, CurrentMonthExceptions + PreviousMonthExceptionsWithZero, CurrentMonthExceptions ) RETURN YTDExceptionsBest Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, arunh100
please find below attached .pbix file
Best Regards,
Dangar
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- arunh1001 year agoFrequent Visitor
Hi Dangar
There is one twist. Count of Task ID is not direct column.Its count of Task ID measure. So I am not getting same result as yours. Kindly advise and suggest
Regards
- Dangar3321 year agoResident Rockstar
Hi, arunh100
Amend measures as belowMeasure = var a = CALCULATE(MAX('Table'[CreatedMthYr]),REMOVEFILTERS('Table'[CreatedMthYr])) var b = MAXX(FILTER(all('Table'),'Table'[CreatedMthYr]<a),'Table'[CreatedMthYr]) var c = CALCULATE([Count of Task ID],'Table'[CreatedMthYr]=b)+[Count of Task ID] RETURN SUMX('Table', IF('Table'[CreatedMthYr]=a,c,[Count of Task ID]))
If this not work then please provide the code of measure that are use for "Task ID" count or some sample data with Task ID Column .Best Regards,
DangarIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.