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
mudegowdrp
Helper II
Helper II

set "first seen" date based on previous records

 

Hi,

 

I have a dataset coming in every week and I have used merged queries to build treands graph to show new records added and see those records which are not resolved.  Please help how can I solve this.

 

Week 1

 

Capture.PNG

 

week 2

Capture.PNG

 

 

 

 

 

I need to add column saying First_Seen

 

So my result dataset should look like

 

IP                                        Vulnerability ID               Date(data exported date)                  First Seen Date

11.1.111.11                          1001                               2/1/2018                                            2/1/2018

11.1.111.12                          1002                               2/1/2018                                            2/1/2018

11.1.111.13                          1003                               2/1/2018                                            2/1/2018

11.1.111.14                          1004                               2/1/2018                                            2/1/2018

11.1.111.15                          1005                               2/1/2018                                            2/1/2018

11.1.111.16                          1006                               2/1/2018                                            2/1/2018

11.1.111.17                          1007                               2/1/2018                                            2/1/2018

11.1.111.18                          1008                               2/1/2018                                            2/1/2018

11.1.111.11                          1001                               2/8/2018                                            2/8/2018

11.1.111.11                          1004                               2/8/2018                                            2/8/2018

 

Same IP will have different Vulnerability ID and vice versa.

But if both are same and occured previously, set first seen date to first occured.

 

Please help.

 

 

Thanks

1 ACCEPTED SOLUTION

OK, taking the example:

 

Uptime = 
VAR next = MINX(FILTER(Repairs,
                       Repairs[MachineName]=EARLIER(Repairs[MachineName]) && 
                       Repairs[RepairStarted]>EARLIER(Repairs[RepairStarted]) && 
                       Repairs[RepairType]<>"PM"
               ),Repairs[RepairStarted])
RETURN IF([RepairType]="PM", 0,IF(ISBLANK(next),
               DATEDIFF([RepairCompleted],NOW(),SECOND),
               DATEDIFF([RepairCompleted],next,SECOND)
           )
       )

Your first seen would probably look like this:

 

First Seen = 
VAR next = MINX(FILTER(Table,
                       Table[Vulnerability ID]=EARLIER( Table[Vulnerability ID])),
Table[Date(data exported date)]) RETURN IF(ISBLANK(next), [Date(data exported date)],next)

So, what you are doing is creating a temp table inside of MINX that has all of your rows that have the same Vulnerability ID. Then you take the MIN value of the Data column. You return that value.


@ 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

7 REPLIES 7
Greg_Deckler
Super User
Super User

See the technique here using EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...

 


@ 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...

@Greg_Deckler Thank you. But I did not get that.

 

I should create a column based on IP and Vulnerability ID. If dataset is having same record I should use the FIRST exported as first seen date. if not I should just use exported date.

 

Please help

OK, taking the example:

 

Uptime = 
VAR next = MINX(FILTER(Repairs,
                       Repairs[MachineName]=EARLIER(Repairs[MachineName]) && 
                       Repairs[RepairStarted]>EARLIER(Repairs[RepairStarted]) && 
                       Repairs[RepairType]<>"PM"
               ),Repairs[RepairStarted])
RETURN IF([RepairType]="PM", 0,IF(ISBLANK(next),
               DATEDIFF([RepairCompleted],NOW(),SECOND),
               DATEDIFF([RepairCompleted],next,SECOND)
           )
       )

Your first seen would probably look like this:

 

First Seen = 
VAR next = MINX(FILTER(Table,
                       Table[Vulnerability ID]=EARLIER( Table[Vulnerability ID])),
Table[Date(data exported date)]) RETURN IF(ISBLANK(next), [Date(data exported date)],next)

So, what you are doing is creating a temp table inside of MINX that has all of your rows that have the same Vulnerability ID. Then you take the MIN value of the Data column. You return that value.


@ 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...

@Greg_Deckler Okay I'm trying this. Thank you for explaing in detail.

No worries, hope you get there. If not, let me know.


@ 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...

@Greg_DecklerIt works fine. Thanks again 🙂

Awesome! Sometimes you can run into trouble with the "X" versions of functions on very large data sets.


@ 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
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.