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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Previous month in a card based on month filter

How do I get the previous month total hours based on the month filter?

Measure 4 = CALCULATE([Total Hours], PREVIOUSMONTH('Jersey'[Posting Date]))
It is showing blank. 
 
Please help 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:

1.my test table

Table:

vbinbinyumsft_0-1661136095869.png

2.add a "Month" column to the table

 

Month = MONTH('Table'[Date])

 

vbinbinyumsft_1-1661136151347.png

3. create two measure and add it to table visual

 

Total Hour = SUM('Table'[Spend Hour]) 
Pre_Total_Hour =
VAR cur_month =
    SELECTEDVALUE ( 'Table'[Month] )
RETURN
    CALCULATE (
        [Total Hour],
        FILTER ( ALL ( 'Table' ), 'Table'[Month] = cur_month - 1 )
    )

 

vbinbinyumsft_2-1661136249033.png

Please refer my attached .pbix file

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:

1.my test table

Table:

vbinbinyumsft_0-1661136095869.png

2.add a "Month" column to the table

 

Month = MONTH('Table'[Date])

 

vbinbinyumsft_1-1661136151347.png

3. create two measure and add it to table visual

 

Total Hour = SUM('Table'[Spend Hour]) 
Pre_Total_Hour =
VAR cur_month =
    SELECTEDVALUE ( 'Table'[Month] )
RETURN
    CALCULATE (
        [Total Hour],
        FILTER ( ALL ( 'Table' ), 'Table'[Month] = cur_month - 1 )
    )

 

vbinbinyumsft_2-1661136249033.png

Please refer my attached .pbix file

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Whitewater100
Solution Sage
Solution Sage

Hi:

The other gemtleman suggested using a date table,marked as date table and then forming a relationship. Please see attached example. I hope this helps!https://drive.google.com/file/d/1QoGYST_Gu96qMO9TURHxRtcO2sj8tmI7/view?usp=sharing 

 

Whitewater100_0-1661129907157.png

 

lbendlin
Super User
Super User

Time intelligence functions are very much expecting a calendar table with contiguous unique dates .  Doesn't look like you have that in your example.

 

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.