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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pbilearning
Helper I
Helper I

how to check for ID's with change in status/category from last 3 months, 6 months, 9 months etc

Hi Everyone,

 

I have a quick doubt please if anyone can help?

 

I am working on a data provided with ID's, months starting from June'19 to March'20(which will extend till June'20) and category/state(text data) of id. I want to look for ID's that have not changed their state from last 3 months, last 6 months,  last 9 months and so on. Can we do that on powerbi? 

categorytrace.JPG

1 ACCEPTED SOLUTION

Updated and attached:

 

3 Months the Same Column = 
  VAR __Current = [Category]
  VAR __Table = FILTER('FactTable1',[Month] <= EARLIER([Month]) && [Month] >= (EARLIER([Month]) - 90) && [ID] = EARLIER([ID]))
  VAR __Check = FILTER(__Table, [Category] <> __Current)
RETURN
  IF(ISBLANK(COUNTROWS(__Check)), "Same", "Changed")

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Yes, you would generally do that something like:

 

3 Months the Same Column =
  VAR __Current = [Category]
  VAR __Table = FILTER('Table',[Month] >= ([Month] - 90))
  VAR __Check = FILTER(__Table, [Category] <> __Current)
RETURN
  IF(ISBLANK(__Check), "Same", "Changed")

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

 

I tried your formula by adding another column in data, but I am getting below error on power bi. Is there anything I am doing wrong3months.JPG

@Greg_Deckler 

I have attached excel file and PBI for your reference.Excel File (Sample) PBI  

 

Really Thanks for your help! 🙂

OK, sorry, try this:

 

3 Months the Same Column = 
  VAR __Current = [Category]
  VAR __Table = FILTER('FactTable1',[Month] >= ([Month] - 90) && [ID] = EARLIER([ID]))
  VAR __Check = FILTER(__Table, [Category] <> __Current)
RETURN
  IF(ISBLANK(COUNTROWS(__Check)), "Same", "Changed")

 

PBIX is attached:

 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

 

Thanks for your quick help 🙂

 

It is working, but its working for account changin for all months rather than just 3 months or 6 months or 9 months.  I have attached PBI with data for other months entire.JPG data included and screenshot for your reference

Updated and attached:

 

3 Months the Same Column = 
  VAR __Current = [Category]
  VAR __Table = FILTER('FactTable1',[Month] <= EARLIER([Month]) && [Month] >= (EARLIER([Month]) - 90) && [ID] = EARLIER([ID]))
  VAR __Check = FILTER(__Table, [Category] <> __Current)
RETURN
  IF(ISBLANK(COUNTROWS(__Check)), "Same", "Changed")

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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