Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Previous Month Target

Hi everyone,

 

I've had a look around but I can't find the answer on the forums.

 

I am trying to duplicate the following measure, but change it so that it gives me the previous month to use as a target value in the KPI Visual:

 

Active Persons:
VAR mindate =
    MIN ( 'Calendar'[Date] )
VAR maxdate =
    MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( DM_PERIODS_OF_CARE ),
        ALL ( 'Calendar' ),
        OR ( DM_PERIODS_OF_CARE[END_DATE] >= mindate, ISBLANK ( DM_PERIODS_OF_CARE[END_DATE] ) ),
        DM_PERIODS_OF_CARE[START_DATE] <= maxdate
    )

 

I have tried to wrap it in 'PREVIOUSMONTH' but can't seem to get it to work. I want to have the KPI show this month's number as the indicator, and have the target be last month's number.

 

Does anyone know how I can fix this?

 

Thanks,

Dan.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please create a Date table and create the below measures, then put the new measures and Date fields of Date table on visual.

Active persons this month =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[PERSON_ID] ),
    FILTER (
        'Table',
        ISBLANK ( 'Table'[END_DATE] )
            || 'Table'[END_DATE] > MAX ( 'Date'[Date] )
    )
)
Active persons last month = CALCULATE([Active persons this month],PREVIOUSMONTH('Date'[Date]))
Active persons same month last year = CALCULATE([Active persons this month],SAMEPERIODLASTYEAR('Date'[Date]))

Best Regards

Rena

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

Could you please provide some sample data(exclude sensitive data) and your desired result in order to provide you suitable formulas for your scenario? In addition, please check if the solution in following threads can help you.

KPI use previous month as target goals

DAX Previous Month to date total is giving entire previous month's entire total

Best Regards

Rena

Anonymous
Not applicable

dwidrascuBG_0-1597658791621.png

Hi @Anonymous please see above the desired result. I want the KPI to show this month's active persons and have it comparing to last month's active persons. The same logic for this month vs same month last year.

 

The DAX code that is currently being used incorporates that the total active persons must show the persons as active in every month, not just one. Active is defined as having a START_DATE and no END_DATE, and they must be counted in each month where they have no END_DATE (for example, PERSON_ID 10 would be counted as active in Jan 09 and Feb 09)

 

Example data:

 

issue.PNG

 

Thanks!

Anonymous
Not applicable

Hi @Anonymous ,

Please create a Date table and create the below measures, then put the new measures and Date fields of Date table on visual.

Active persons this month =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[PERSON_ID] ),
    FILTER (
        'Table',
        ISBLANK ( 'Table'[END_DATE] )
            || 'Table'[END_DATE] > MAX ( 'Date'[Date] )
    )
)
Active persons last month = CALCULATE([Active persons this month],PREVIOUSMONTH('Date'[Date]))
Active persons same month last year = CALCULATE([Active persons this month],SAMEPERIODLASTYEAR('Date'[Date]))

Best Regards

Rena

amitchandak
Super User
Super User

@Anonymous , Is the calendar is marked at date table? Option right click of a table .

after that these should work

 

Last Day = CALCULATE(COUNTROWS ( DM_PERIODS_OF_CARE ), previousmonth('Calendar'[Date]))
last MTD Sales = CALCULATE(COUNTROWS ( DM_PERIODS_OF_CARE ),DATESMTD(dateadd('Calendar'[Date],-1,MONTH)))

 

also check fo these resons

Sales Date 1= [Sales Date].Date
Sales Date 2= Date(Year([Sales Date]), Month([Sales Date]), Day([Sales Date]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.