Power BI and Excel daily report - excel

I’m receiving a daily excel sheet report that contains daily incidents
My task is the following:
1- Consolidate the daily with the master sheet (including update the status of already existed TTs)
2- Calculate the SLA
3- Update charts for the TTs exceeded SLA
I was searching online to find a mechanism to automate the process by automate the merge using power automate then use power query to calculate the SLA finaly use power bi to visualise the data.
I would highly appreciate if anyone could advice me if my approach is right or to suggest another way.
Thanks a lot

your tasks are not clear, which connections are you using or if you consolidate in excel or where-else ?
if you don't need to do anything in excel, did you try to refresh it on the server?
Go to Data Hub --> https://app.powerbi.com/datahub (or your local server)
Settings ---> Scheduled Refresh

Your request seems a little vague, but, at least for the first part, it seems like you want to automate the process of automating worksheets. Check out the VBA script below. Get that working, then move on to step #2 and step #3.
Sub Combine()
'UpdatebyExtendoffice
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End Sub
https://www.extendoffice.com/documents/excel/1184-excel-merge-multiple-worksheets-into-one.html

Related

Updating Charts in Manual Calculation Mode (Excel for Mac 2016)

I have a large workbook from which I am trying to build reports, including multiple graphs. The workbook has to be in Manual Calculation mode to work. I have compartmentalized the calculations into different sheets, and written vba scripts to run calculations on different combinations of sheets. The problem I am running in to is that after I run these scripts, the graphs that I have will not update. The data does update, and if I manually go in to the graph and "select data" and re-select the same data then they will update. Is there a way I can automate this at the end of my script? I have tried different suggestions on different forums, but nothing seems to work. Here is the code I am currently working with, but it will not update the graphs:
Sub Calculate1()
Sheets("Sheet 1").Calculate 'Sheet with calculations
Sheets("Sheet 2").Calculate 'Sheet referencing final numbers from sheet 1, and displaying graphs
Dim co As ChartObject
For Each co In Sheets("Sheet 2").ChartObjects
co.Chart.Refresh
DoEvents
Next co
End Sub
Thanks for taking the time to look! I am running Excel for Mac 2016. One suggestion that has been made on other forums is to momentarily set the calculation mode to automatic, but this is not an option for me, as that will crash the program.
This snippet should work:
' Force the charts to update
Set sht = ActiveSheet
For Each co In sht.ChartObjects
co.Activate
For Each sc In ActiveChart.SeriesCollection
sc.Select
temp = sc.Formula
sc.Formula = "=SERIES(,,1,1)"
sc.Formula = temp
Next sc
Next co
Credits: https://stackoverflow.com/a/11581258/2707864
This might also work (YMMV):
Worksheets("Sheet 2").Cells.WrapText=False
' Run your calculations
Worksheets("Sheet 2").Cells.WrapText=True
Credits: https://stackoverflow.com/a/7211065/2707864
See also
Refresh all charts without blinking (and this comment).
Excel chart won't update
You should be able to add co.calculate after your loop. You might also just be able to change Application.Calculation = xlAutomatic before your loop, and then change back to Application.Calculation = xlManual after the loop.

Update Bloomberg API static data

I want to copy and paste data from one sheet to another sheet. The original data is from Bloomberg API function. I found the Bloomberg data cell only updates after the macro finishes running. I tried to build a private function to let the static data update before I copy it. Here is my code:
Private Sub ProcesData()
Application.Run
Call Application.OnTime(Now + TimeValue("00:00:01"), "ProcessData")
End Sub
Sub Macro3()
Dim i As Integer
i = 1
Do Until i > 2
Sheets("Sheet1").Activate
Cells(1, 3).Value = Cells(i, 1)
i = i + 1
Call Application.OnTime(Now + TimeValue("00:00:01"), "ProcessData")
Range("C4:E181").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Loop
End Sub
Ah, Bloomberg API... many an issue.
So, when you do a Bloomberg request using a function call, the cell call site receives a call back and refreshes the data.
The problem is, w.r.t. automation, the data can come back in parts and you have to wait till it completes before continuing to process your data.
So, there are 3 approaches to this solution.
Last time I looked, this is the one that Bloomberg recommends. Have a routine that refreshes the call to the cell formula. This has a timer and recursively invokes itself until the data has been retrieved. The trick to this is to know when the data has been retrieved correctly. The data area is checked for errors which say it hasn't been completed yet.
The other solution is to invoke the call using Application.Run where you build the formula in code and invoke with VBA. This allows you to not deal with functions as such in the worksheet. But is effectively the same thing as 1.
You can set a reference to the Bloomberg API and use COM to do the request. This is a much cleaner approach and you can easier integrate this into your code effectively creating a Bloomberg data call API.
I would suggest, if possible going for option 3. Although a little more effort, te code becomes much cleaner. Options 1. and 2. can be tricky to debug when your workbooks become more complex in terms of structure etc.
If you search your Bloomberg help (the ever tremendous old 'F1 F1' help service should be able to point you in the right direction. Simply the most impressive help system ever done in my opinion!) Bloomberg does have some examples which demonstrate the methods highlighted above.
So, with the issue at hand and to finally answer your question :)
I would restructure your code to actually do function call that initially does a Calcuation (which will invoke your requests to Bloomberg). Then enter into a recursive function which calls itself until there are no errors in the data. After this you then copy your data.
Hope that helps.

Display values greater than a specific number

I have a report in Excel which lists clients and the amount of hours that we work on them.
I want to create a separate sheet within this workbook that pulls the clients that we work on over 40 hours, through VBA.
For example basic version of my report looks like this in Sheet 1
Client------Client ID---Hours
Client 1------1947--------30
Client 2------6465--------46
Client 3------8787--------20
Client 4------7878--------15
Client 5------4873--------48
I want my new sheet to display
Client------Client ID---Hours
Client 2------6465--------46
Client 5------4873--------48
I am wondering if it is a while loop but wouldn't it break as soon as it finds the first value greater than 40 then it wouldn't continue to the next set of values?
I recorded a quick macro to get the code for the filter criteria and then used Copy Destination:= . Recording macros and reviewing them is a great way to start learning some VBA
Sub Shorty()
Cells.Select
Selection.AutoFilter
ActiveSheet.UsedRange.AutoFilter Field:=3, Criteria1:=">40", _
Operator:=xlAnd
ActiveSheet.UsedRange.Copy Destination:=ActiveWorkbook.Sheets("Sheet2").Range("A1")
Selection.AutoFilter
End Sub
You can find the documentation for the Copy Method here

excel cannot complete this task with available resources

When i'm trying to copy the data in one of the worksheets into new sheet using the below code in EXCEL 2007, WINDOWS 7, I'm facing with the error "excel cannot complete this task with available resources. choose Less data or close other applications".
when i close all other applications, its showing the same message. How to resolve this issue? Please advise.
With ActiveSheet
.Range("A1").Select
.UsedRange.SpecialCells(xlCellTypeVisible).Copy
End With
With ThisWorkbook
Set ws = .Worksheets.Add(After:=.Sheets(.Sheets.count))
NewSheet = ActiveSheet.Name
End With
With ActiveSheet
.Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths
Selection.PasteSpecial xlPasteAll
.Range("A1").Select
End With
When i save the xls as .xls (97-2003) its working fine. But i want to run with more data than 65k
I tested your code on a newly created excel document and copied 80K rows to a new sheet.
Your code works...
I did however create it as a macro sub routine and run it multiple times to check.
But you said you saved your document once as a xls. Maybe you got the limitations with it also.
Please and create a new excel document and always save it as xlsx...

Excel Filtering and Copying in VBA

I'm working on a VBA script that pulls a range of dates from Access, then filters the data and creates a chart based on the filtered data. The filtered data will be going to a separate sheet where the chart will be pulling its data from . I can get data out of Access with a SQL statement, but my AutoFilter in Excel is erroring out. Here is what I have...
Sheet3.Range("F4:F500").AutoFilter(, "Riveter 01").Copy Destination:=Sheet2.Range("A5")
It gives an app-defined or object-defined error and I can't figure out why. Is this the proper way or is there an easier way?
PS: This filter will happen with 22 unique machines so I was planning on running a loop for each machine. If that is not the fastest or proper way please let me know.
You need to split this into two parts. Filter and then copy/ paste. See below:
With Sheet3
.AutoFilterMode = False
With .Range("F4:F500")
.AutoFilter Field:=1, Criteria1:="Riveter 01"
.SpecialCells(xlCellTypeVisible).Copy Destination:=Sheet2.Range("A5")
End With
End With
to remove the filter:
On Error Resume Next
Sheet3.ShowAllData
On Error GoTo 0
On Error Resume Next is for when there is no filter present to skip the error. Please note the use of Sheet3 and Sheet2 for those looking for a generic solution.
I think that you have to do this in 2 separate steps:
filter the data
copy the filtered data to another sheet
The answer here has an excellent example of how to do this: Autofilter Macro, then copy visible data ONLY and paste to next available row

Resources