0
votes

How can I count records captured in the previous month. I have a table with a date time column as seen in the image. Challenge is that the measure is not counting all records for the previous month (December 2019) yet we are in (January 2020). I believe issue might be with the year change. Below is my measure code for review.

CALCULATE(
    IF(
        ISBLANK(
            COUNT(audit_requests[agent_id])), 0, COUNT(audit_requests[agent_id]
        )
    ), 
    FILTER(
        audit_requests, 
        YEAR(audit_requests[createdtime]) = IF(MONTH(TODAY()) = 1, YEAR(TODAY()) - 1, YEAR(TODAY())) && 
        MONTH(audit_requests[createdtime]) = IF(MONTH(TODAY()) = 1, "12", MONTH(TODAY()))
    )
)```

1

1 Answers

1
votes

Have found a solution. Turns out I needed to remove the quotes from "12" to 12 so that Power BI can recognize it as a number as is it performs the comparisons with the data