DAX query Calculation Help

Hi,

I need help with Dax query for below so instead of Count I need to get Desire Count.

Let say if current month is June and Type is PHC in March the count will be (March + april+ May+ Jun) which is (34 + 177 + 58 + 11) = 280. For April it will exclude March count which is 34 so April will be (177 + 58 + 11 ) = 246 etc

image

Another e.g. for current month (April) data would need to look like below

March

Last eg. let say if the month was May it result would be like this.

April

Thanks

Hi @asif082 ,

Here’s a DAX example to get you started:

DAXCopy codeDesire Count = VAR CurrentMonth = MONTH(TODAY())VAR CurrentYear = YEAR(TODAY())VAR SelectedMonth = MONTH('Table'[DATE])VAR SelectedYear = YEAR('Table'[DATE])RETURN IF(    SelectedMonth <= CurrentMonth && SelectedYear = CurrentYear,    CALCULATE(        SUM('Table'[Count]),        FILTER(            ALL('Table'),            'Table'[Type] = EARLIER('Table'[Type]) &&            'Table'[Month] >= 'Table'[Month] &&            'Table'[Year] = 'Table'[Year]        )    ),    BLANK())

This formula helps to accumulate the counts from the selected month backward, excluding previous months as specified. For more specific solutions, please use the Data Mentor site.

Cheers,

Enterprise DNA Support Team