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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Lobs
Helper II
Helper II

Previous Month Segment

Hi All, 

 

Im trying to get a value coming from the previous month on the same table, 

 

I tried the following, but always got blank results. 

PM Segment = CALCULATE (
FIRSTNONBLANK(Roster[Segments_], 1 ),
FILTER ( ALL ( Roster ), Roster[IDFDATE]= Roster[IDPMFDATE] )
)
my table has the following
Lobs_0-1617611762576.png

IDFDate = ID and Current Month

IDPMFDATE = ID and Previous Month

 

any idea why its showing as blank?

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Lobs ,

 

FILTER ( ALL ( Roster ), Roster[IDFDATE]= Roster[IDPMFDATE] )

The problem may be in this filter condition.

 

Please try this:

Column = CALCULATE(FIRSTNONBLANK(Roster[Segments_],1),FILTER(Roster,EARLIER(Roster[IDFDATE])=Roster[IDFDATE]&&Roster[IDPMFDATE] IN VALUES(Roster[IDFDATE])))

If segment is obtained by month, create two columns respectively to represent the current month and previous month, and the formula is similar to the above.

 

Best Regards,
Liang
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
V-lianl-msft
Community Support
Community Support

Hi @Lobs ,

 

FILTER ( ALL ( Roster ), Roster[IDFDATE]= Roster[IDPMFDATE] )

The problem may be in this filter condition.

 

Please try this:

Column = CALCULATE(FIRSTNONBLANK(Roster[Segments_],1),FILTER(Roster,EARLIER(Roster[IDFDATE])=Roster[IDFDATE]&&Roster[IDPMFDATE] IN VALUES(Roster[IDFDATE])))

If segment is obtained by month, create two columns respectively to represent the current month and previous month, and the formula is similar to the above.

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Lobs , not very clear, But you should use time intelligence with date table example

 

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

 

 

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks Amit, what if i wanted to show just a Value (in this case a Letter) what expression can i use?

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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