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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Was this risk in this status last month?

I have a table let's say "Risk status table" with the Risk ID, Status, Start of month, Risk ID and Status and what I want to work out New or same status

 

Risk IDStatusStart of monthRisk ID and Status

New or same status

R11S101/01/2020R11 S1New Status
R12S101/01/2020R12 S1New Status
R11S101/02/2020R11 S1Same Status
R12S201/02/2020R12 S2New Status
R13S101/02/2020R13 S1New Status
R11S201/03/2020R11 S2New Status
R12S301/03/2020R12 S3New Status
R13S101/03/2020R13 S1Same Status

R14

S101/03/2020R14 S1New Status

 

Above is an example of data, and what I'd expect the calculated column to be. So the calculated column in Jan is all New status since there is no data before that. In Feb, the Risk ID R11 has a status of S1 which it was also in the previous month, so the calculated column is Same Status, and in Feb R12 has changed to status S2 which it wasn't the previous month so the calculated column is New Status.

 

The logic I want to use in the new calculated colum (New or same status) is to see if the string in the "Risk ID and Status" column appears in the previous month, if the string does appear in the previous month then it's the Same Stauts, if it does not then its a New Status

1 ACCEPTED SOLUTION

@Anonymous - This worked, updated PBIX attached.

Column = 
    VAR __PreviousDate = MAXX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]<EARLIER([Start of month])),[Start of month])
    VAR __Previous = MAXX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]=__PreviousDate),[Status])
    VAR __Count = COUNTX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]<EARLIER([Start of month])),[Risk ID])
RETURN
    IF(__Count<0 || [Status]=__Previous,"Same Status","New Status")


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@Anonymous - I mocked this up in the standard way, in attached PBIX Table (25) but for some reason it is not recognizing the return as blank (first occurrence). Maybe something is up with my system? Anyway, see if you get similar results for first occurrences being "Same Status".

Column = 
    VAR __PreviousDate = MAXX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]<EARLIER([Start of month])),[Start of month])
    VAR __Previous = MAXX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]=__PreviousDate),[Status])
RETURN
    IF(ISBLANK(__PreviousDate) || [Status]=__Previous,"Same Status","New Status")


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Anonymous - This worked, updated PBIX attached.

Column = 
    VAR __PreviousDate = MAXX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]<EARLIER([Start of month])),[Start of month])
    VAR __Previous = MAXX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]=__PreviousDate),[Status])
    VAR __Count = COUNTX(FILTER('Table (25)',[Risk ID]=EARLIER([Risk ID]) && [Start of month]<EARLIER([Start of month])),[Risk ID])
RETURN
    IF(__Count<0 || [Status]=__Previous,"Same Status","New Status")


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous , create a new column like


new column =
var _date = maxx(filter(table,[Risk ID] = earlier([Risk ID]) && [Start of month] <earlier([Start of month])),[Start of month])
var _st =maxx(filter(table,[Risk ID] = earlier([Risk ID]) && [Start of month] =_date),[Status])
return
if(isblank(_st), "New Status", if(_st = [Status] ,"Same Status", "New Status"))

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.