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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
seanrm42
Frequent Visitor

Recording Daily Data

I am pulling my data from a SQL Database which contains records of devices being scanned for an asset management solution.

 

Everyday each device (device ID is unique), which can be reached via our network, sends data back to the database and upon doing so, updates a "Last Scan Date" column.

 

In a perfect world, all devices would check in everyday but, in an enterprise world, that is not plausible. This means I have devices (rows) which have a Last Scan Date of a previous date other than today. Since the devices which sent data on the previous day send data again on the current day, I do not have a rolling count of the total quantity of devices which scanned in each day. 

 

I would like to create a way for recording the daily total count of devices which sent data on that day and storing these records in a table which I can then create a visualization for. 

 

For example:

 

Day 1 (6/13/17) = 7 devices found; 0 devices not found; 0 new devices found

 

ID                    Last Scan Date

Computer 1     6/13/2017

Computer 2     6/13/2017

Computer 3     6/13/2017

Computer 4     6/13/2017

Laptop 1          6/13/2017

Laptop 2          6/13/2017

Laptop 3          6/13/2017
  

Day 2 (6/14/17) = 8 devices found; 2 devices not found; 3 new devices found

 

ID                    Last Scan Date

Computer 1     6/14/2017

Computer 2     6/14/2017

Computer 3     6/13/2017

Computer 4     6/14/2017

Computer 5     6/14/2017

Laptop 1          6/13/2017

Laptop 2          6/14/2017

Laptop 3          6/14/2017

Laptop 4          6/14/2017

Laptop 5          6/14/2017


....and so on 

 

Does anyone have a solution for achieving this in Power BI?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @seanrm42,

 

You can take a look at below steps to analysis the history data.

 

Steps:

1. Get the history current device list.

_history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
_current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))


2. Calculate the different count.

 

Calculate columns:

 

Analysis Data = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var devices_found=COUNTROWS(_current) //Found : current list
var devices_not_found=COUNTROWS(EXCEPT(_history,_current))+0 //Not found: devices which exist in history but not in current
var new_devices=COUNTROWS(EXCEPT(_current,_history))+0 //New device: devices which exist in current but not in history
Return
"found: "&devices_found&" , not found: "&devices_not_found&" , new: "&new_devices

Detail list:

Found Detail = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var  devices_found=COUNTROWS(_current)
Return
CONCATENATEX(_current,[ID],",")

Not Found Detail = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var devices_not_found=COUNTROWS(EXCEPT(_history,_current))+0
Return
CONCATENATEX(EXCEPT(_history,_current),[ID],",")

New Devices Detail = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var new_devices=COUNTROWS(EXCEPT(_current,_history))+0
Return
CONCATENATEX(EXCEPT(_current,_history),[ID],",")

4.PNG

 

 

3. Create a table visual to show these result.

 5.PNG

 

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @seanrm42,

 

You can take a look at below steps to analysis the history data.

 

Steps:

1. Get the history current device list.

_history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
_current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))


2. Calculate the different count.

 

Calculate columns:

 

Analysis Data = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var devices_found=COUNTROWS(_current) //Found : current list
var devices_not_found=COUNTROWS(EXCEPT(_history,_current))+0 //Not found: devices which exist in history but not in current
var new_devices=COUNTROWS(EXCEPT(_current,_history))+0 //New device: devices which exist in current but not in history
Return
"found: "&devices_found&" , not found: "&devices_not_found&" , new: "&new_devices

Detail list:

Found Detail = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var  devices_found=COUNTROWS(_current)
Return
CONCATENATEX(_current,[ID],",")

Not Found Detail = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var devices_not_found=COUNTROWS(EXCEPT(_history,_current))+0
Return
CONCATENATEX(EXCEPT(_history,_current),[ID],",")

New Devices Detail = 
var _history=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]<EARLIER(test[Last Scan Date])))
var _current=CALCULATETABLE(VALUES(test[ID]),FILTER(ALL(test),[Last Scan Date]=EARLIER(test[Last Scan Date])))
var new_devices=COUNTROWS(EXCEPT(_current,_history))+0
Return
CONCATENATEX(EXCEPT(_current,_history),[ID],",")

4.PNG

 

 

3. Create a table visual to show these result.

 5.PNG

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.