Is it possible to change format cells in result table? I am doing some summarize using PowerBI using number format. But after summarize I want to change to duration. I can change data source type but Power Bi dont support format "dd:hh:mm:ss" only "hh:mm:ss" so if some action cost 45 hours power bi show only 21:00:00 instead of 01:21:00:00(this is format that I want to achive, but if I change it in data source I cannot summarize it because it is text).
You can try this :
FormatTime =
VAR h = INT('Table'[yourColumn]/3600)
VAR m = FORMAT(INT(DIVIDE(MOD('Table'[yourColumn],3600),60)), "00")
VAR s = FORMAT(INT(MOD(MOD([yourColumn],3600),60)),"00")
RETURN
h& ":" & m & ":" & s
Also don't forget to change FormatTime column to the type Time.
Related
I would like to pass 2 date parameters from cells in my excel workbook with the following Kusto query in power query of excel.
= AzureDataExplorer.Contents("https://test.net/", "myDB", "table#(lf)| where ChangedOn >= datetime(2023-02-01 00:00:00) and ChangedOn <= datetime(2023-02-28 23:59:59)", [])
= AzureDataExplorer.Contents("https://test.net/", "myDB", "table#(lf)| where ChangedOn >= datetime(" & "2023-02-01 00:00:00" & ") and ChangedOn <= datetime(" & "2023-02-01 00:00:00" & ")", [])
= AzureDataExplorer.Contents("https://test.net/", "myDB", "table#(lf)| where ChangedOn >= datetime(" & myParameter1 & ") and ChangedOn <= datetime(" & myParameter2 & ")", [])
myParameter1 = a start date value from a cell in excel
myParameter2 = an end date value from a cell in excel
The first 2 examples work in fetching the data but I am not able to figure out how to create and pass a custom date parameter that comes from a cell in excel. I would like ability to change start and end dates in excel and fetch those records after clicking refresh.
Define a range name in excel, and populate it
Read that value into powerquery
Date1= Excel.CurrentWorkbook(){[Name="date"]}[Content]{0}[Column1],
replace hard coded date with reference to that variable, properly formatting it with DateTime.ToText using documentation at
https://learn.microsoft.com/en-us/powerquery-m/datetime-totext
example
Date1= Excel.CurrentWorkbook(){[Name="date"]}[Content]{0}[Column1],
Source = "where ChangedOn >= datetime(2023-02-01 00:00:00)",
Source2 = "where ChangedOn >= datetime("&DateTime.ToText(Date1, [Format="yyyy-MM-dd HH:mm:ss"])&")"
i have sheet including a start date & sf id and I need to combine them in one column as a reference but when I try to do this I found an error as shown in the P.S, So can I solve this error
Try using
= Text.From([Date]) & Text.From([Person ID])
or perhaps
= Text.From([Date]) & " " & Text.From([Person ID])
If the field is not text, you can not combine it using a & unless you wrap it with Text.From()
I am new to Excel VBA. I used VBA to extract data from SQL-Server and was able to extract data using text filters but when I started filtering by date, it didn't work anymore. I think my mistake was the formatting of date. I tried using all the samples on this site but I'm beginning to be hopeless. It would be great if you guys can assist me with this hurdle. Thanks a million.
Here's the code: (Please take note that I am skipping the connection and close codes to focus only on the problematic source code).
What I want to achieve here in this code is to extract all the records (using SQL query in a VBA environment) based on date criteria which is greater than or equal to January 1, 2018.
query = "SELECT (Worktype), count(*)" & _
"FROM dbo.InteractionSummary WHERE [Worktype] IN ('" & MAC & "')" & _
"GROUP BY [Worktype]"
With this query, I had no issue. It has generated the figures perfectly. What these codes do is to count all the records from "Worktype" column that has "MAC" value.
My issue is when I add the below date criteria.
Dim dTheDate As Date
dTheDate = #1/1/2018#
query = "SELECT (Worktype), count(*)" & _
"FROM dbo.InteractionSummary WHERE [Worktype] IN ('" & IMAC & "')" & _
"GROUP BY [Worktype] AND [StartDateTimeUTC] > " & dTheDate & " "
StartDateTimeUTC is a DateTime2 column (datetime2(3),notnull). I'm trying to extract only based on the dTheDate. I tried every format but it's not letting the code through.
Thanks,
Skywalker
data will be read from excel sheet & store data table& i will insert data in database(oracle).but term column in database accept 7 bytes like mm/yyyy . but my input read data will be date time format.how can i do date time to mm/yyyy
below is oracle insert query
strQuery &= "'" + String.Format("{%M/%y}", dt1.Rows(row)("TERM")) + "',"
When you read the date/time from excel, assign the value to datetime variable and then you can pull the month and year from.
I'm fetching data through an SQL statement in PowerQuery:
let
Source = Oracle.Database("sampleDB", [Query="SELECT * FROM mySampleTable WHERE CustomerID in (1,2,3,4,5)"])
in
Source
I need the SQL filter to be dynamic. So I have another query with a single cell containing a text string. For the example above, the single cell looks like => "1,2,3,4,5". This is why I want to build a dynamic SQL statement in PowerQuery that references that single cell from my other query.
I've tried the code below and other variants but none work!:
let
Source = Oracle.Database("sampleDB", [Query="SELECT * FROM mySampleTable WHERE CustomerID IN (" & MyReferenceQuery["SingleCell"] & ")"]
in
Source
How can I reference this other query?
If the text is in a single cell in a table, you need to access the value by specifying a column and a row-index, like below:
= Oracle.Database("sampleDB", [Query = "SELECT " & MyReferenceQuery[Column1]{0} & " FROM Table"])