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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wuxxx711
Frequent Visitor

Last month total by Category

Hi guys,

 

I am new in PB. I have one fact table as below,

 

CategoryItemDate Total
Aa1/1/202110
Ab1/1/202115
Ac1/1/202120
Ab2/1/20215
Ad2/1/202110
Be1/1/202120
Bf1/1/202130
Be2/1/202140
Bg2/1/202150
Bh2/1/202160

 

I would like the result as below,

CategoryCurrent Month Total(e.g.Feb)Last Month Total(e.g.Jan)
A1545
B15050

 

The would be more Date add in later and more Categories as well.

My question is I want Date as my filter. and how I can calculate "Last Month Total" in this case?

 

Thanks in advance.

1 ACCEPTED SOLUTION
v-yetao1-msft
Community Support
Community Support

Hi  @wuxxx711 ,

You can follow these steps

(1)Create a date table and use time intelligence .

Date = CALENDAR(DATE(2021,01,01),DATE(2021,04,01))

(2)Create two measures to sum the current month total and last month total

Current Month Total = SUM('Table'[Total])

Last Month Total = CALCULATE(SUM('Table'[Total]),PREVIOUSMONTH('Date'[Date]))

(3)Create a relationship between Table and Date

(4)Add a visual with  ‘Table[Category],Date[Current Month Total],Date[Last Month Total]

 

The effect is as shown:

Ailsa-msft_0-1616382578294.png

 

Ailsa-msft_1-1616382578298.png

 

 

 

Best Regards

Ailsa Tao

View solution in original post

2 REPLIES 2
v-yetao1-msft
Community Support
Community Support

Hi  @wuxxx711 ,

You can follow these steps

(1)Create a date table and use time intelligence .

Date = CALENDAR(DATE(2021,01,01),DATE(2021,04,01))

(2)Create two measures to sum the current month total and last month total

Current Month Total = SUM('Table'[Total])

Last Month Total = CALCULATE(SUM('Table'[Total]),PREVIOUSMONTH('Date'[Date]))

(3)Create a relationship between Table and Date

(4)Add a visual with  ‘Table[Category],Date[Current Month Total],Date[Last Month Total]

 

The effect is as shown:

Ailsa-msft_0-1616382578294.png

 

Ailsa-msft_1-1616382578298.png

 

 

 

Best Regards

Ailsa Tao

amitchandak
Super User
Super User

@wuxxx711 , use time intelligence with date table

example

MTD Sales = CALCULATE(SUM(Table[Total]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Table[Total]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Table[Total]),previousmonth('Date'[Date]))

 

refer

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.