Quantcast
Channel: All Power Query posts
Viewing all 122482 articles
Browse latest View live

Re: Modify timestamp across many (20) tables by batch process

$
0
0

Hi ,

unfortunately, you have to add a step to every table.
Unless you combine all tables into one table at first and then transform the column Timestamp at once. It depends on what your next step is going to be.

 

An example how to use the conversion:

let
    Source = Sql.Databases("10.7.10.186\RCARCHIVE"),
    #"ROY BICKELL SCHOOL" = Source{[Name="ROY BICKELL SCHOOL"]}[Data],
    dbo_1000MTL24 = #"ROY BICKELL SCHOOL"{[Schema="dbo",Item="1000MTL24"]}[Data],TimestampWithoutSeconds = Table.TransformColumns(dbo_1000MTL24, {{"Timestamp", each #time(Time.Hour(_), Time.Minute(_), 0)}})in
    TimestampWithoutSeconds

Re: On-Prem Gateway - Enterprise mode - oAuth2 authentication with refresh token

$
0
0

Hi  

First which error do you meet?

 

Please follow this guide step by step

https://docs.microsoft.com/en-us/power-bi/service-gateway-custom-connectors

 

Pay attention to the consideration:

  • For custom connectors to work with the On-premises data gateway, they need to implement a “TestConnection” section in the custom connector’s code. This is not required when using custom connectors with Power BI Desktop. You can have one that works with the Desktop, but not with the gateway for this reason. Please refer to this documentation on how to implement a TestConnection section.

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Re: Prevent loading times irrelevant Excel tabs

$
0
0

Hi  

If you want to import only one sheet from an excel file instead of all sheets, you could select only one sheet from the pop window.

5.png

 

If you import many sheets, but you want only one sheet to refresh when clicking "refresh" button from Power BI Desktop,

Uncheck the "include in the report refresh" for the queries which you don't want to refresh,

Close &&apply

Click on "refresh" from Home->Refresh, then this query will not update.

6.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Re: Power BI taking ages to apply query changes

$
0
0

The model you work on will be used with the PowerBI visuals, correct?

 

The logic you describe should be much easier to achieve in DAX, possibly even without storing cumulative values, but just with cumulative measures. Is that an option for you or is there a particular reason why you need to store the data in the table like that?

 

Re: Power BI taking ages to apply query changes

Pseudo code

$
0
0

Hi 

 

I have a pseudo code which I need to put into Power bi. As Im new to both I need some help with putting the code in Pbi

 

The energy reading im pulling out of the database vary from 2-6 seconds per minute. I need to fill in th egaps so that their are readings every minute to work out the KWH (kilo watts/hour)

 

Array  Readings[Num_Energy_Readings]

Array CorrectedReadings[Num_Energy_Readings]

Count =0

EnergyAdjust = 0

TimeOffset=Readings[0]              ‘ Set energy to 0 at the first time required to clear previous energy

CorrectedReadings[0]=Readings[0]-TimeOffset    ‘ Load first readings

For count=1 to count = Num_Energy_Readings

{

                If Readings[count] <  Readings[count-1]

                {

                                EnergyAdjust=EnergyAdjust + Readings[count-1]

                }

                CorrectedReadings[count]=Readings[count]+EnergyAdjust[]-TimeOffset

}

Re: Faster append query

$
0
0

Hi  

After you append queries together, you click on "refresh preview" button, right?

 

Please try to uncheck "enable load" or "included in report refresh" for the original queries.

In this way, the three original queries will not be loaded in the data model and it can reduce memory consumption.

 

Reference:

Performance Tip for Power BI; Enable Load Sucks Memory Up

Speeding up power query

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Re: Return a column if a computed colTumn met the criteria

$
0
0

Hi  

Yes

You could filter it by filter pane

7.png

 

Best Regards
Maggie


Re: Prevent loading times irrelevant Excel tabs

$
0
0

Thanks a lot for your reply Maggie,

 

I would like te import a single sheet from an excel file. Like you suggested, I'm only selecting a single sheet. But, during import and refresh it still displays loading times for all other sheets.

 

Hopefully the below screenshots will show.

 

Knipsel.PNG

 

What is the best way to apply Nested Relationship same as SQL Statements?

$
0
0

Hello,

 

I'm trying to achieve the following SQL Statement's result into Power BI.

SELECT Coalesce(c.name, 'Andre Transportører') AS name, 
       Count(*)                                 Bookings, 
       Coalesce(t2.totinv, 0)                   AS Invoiced, 
       Coalesce(t2.freightcost, 0)              AS InvFreight, 
       Count(*) - Coalesce(t2.totinv, 0)        AS NotInvoiced, 
       Coalesce(t2.freightcost, 0) / Coalesce(t2.totinv, 1) * ( Count(*) - 
       Coalesce(t2.totinv, 0) )                 AS Avsetning 
FROM   carriers c 
       right join tplbookings t 
               ON c.id = t.carrierid 
       left join (SELECT i.carrierid, 
                         Coalesce(Count(*), 0)                        AS TotInv, 
                         SUM(Coalesce(w.netamount, 0) 
                             + Coalesce(w.totalamountfromcharges, 0)) AS 
                         FreightCost 
                  FROM   waybills w 
                         inner join invoices i 
                                 ON w.invoiceid = i.id 
                  WHERE  i.invoicestatus <> 'Draft' 
                         AND i.customerid = 1067 
                         AND w.departuredate BETWEEN 
                             '2019-06-01' AND '2019-06-30' 
                  GROUP  BY i.carrierid) t2 
              ON t.carrierid = t2.carrierid 
WHERE  t.customerid = 1067 
       AND departuredate BETWEEN '2019-06-01' AND '2019-06-30' 
GROUP  BY c.name, 
          t2.totinv, 
          t2.freightcost 
ORDER  BY Count(*) DESC

I 'm getting the following end result with above SQL Statement.

Screenshot_3.png

Now, I have tried to apply the same relationship within my Power BI tables and and take all the parameters from the where conditions as a slicer in Power BI and Select statement as a column from table. Still I'm not getting the correct result.

 

What I'm missing here in relationship? Or what is the best way to achieve this type of result in Power BI?

Screenshot_4.png

 

Any help really appriciated !


Thanks

Re: Referenced Query and Caching question - explanation/confirmation required

$
0
0

Hi  ,

Actually, if you reference the table from SQL Server in query editor, the underlying data source will be queryed in SQL Server.

What do I need to do (set/configure) so the source SQL Server/database is only query the once and the other 13 tables just reference the 'K8 Extract' table and do not impact the source SQL Server/database over and over?


As  aworkaround, you could export your table in SQL Server to excel and then get data with Excel connector in power bi so that it will not query in the sql server.

Hope    and  have other ideas.

Best  Regards,

Cherry

 

Nested table issue with TransformColumns

$
0
0

Hello Experts,

 

I would like to transform following tables into the same cell in this format:

“Prop1=wood,abc;Prop2=red,red2;Prop3=ok,ok2;Prop4=400,ooo1,ooo2”

 

(I was somehow able to transfor from prop1-3, but get stuck at prop4)

Can you please help me with the proper syntax?

 

 

Input xml sample:

 

<?xml version="1.0" encoding="UTF-8"?>
<documents>
<document>
<property>
<name>prop1</name>
<subprop>
<value1>wood</value1>
<value2>abc</value2>
</subprop>
</property>
<property>
<name>prop2</name>
<subprop>
<value1>red</value1>
<value2>red2</value2>
</subprop>
</property>
<property>
<name>prop3</name>
<subprop>
<value1>ok</value1>
<value2>ok2</value2>
</subprop>
</property>
<property>
<name>prop4</name>
<subprop>
<value1>400</value1>
<value2>
<value3>ooo1</value3>
<value4>ooo2</value4>
</value2>
</subprop>
</property>
</document>
</documents>

 

 

 

Thank you very much,

Best Regards,

Zefi

Re: Referenced Query and Caching question - explanation/confirmation required

$
0
0

  - thanks for your reply.

 

"Actually, if you reference the table from SQL Server in query editor, the underlying data source will be queryed in SQL Server."
If I have understood you correctly then yes I am aware that if you place a SQL query inside the 'SQL statement' part of a SQL Server connection (Import Mode) then the query itself will be executed upstream on the actual SQL Server database. This is my intention.

"As  aworkaround, you could export your table in SQL Server to excel and then get data with Excel connector in power bi so that it will not query in the sql server."

This wouldn't be an option due to company specific reasons.
More importantly, I would like all steps to be handled in Power Query so I am keen to understand if what I have stated, in my first post, is to be expected and therefore I have mis-understood the query-folding aspect, or do I need to configure things differently so to get my desired intention of querying the SQL Server database just the once??

Is it possible to have an If function in another If function

$
0
0

Hi 

I'm interested in moving this DAX formular into Power Query: 

S1 = IF(IF('STATUS 1'[t2s1q4] >2;1;0)+If('STATUS 1'[t2s1q5] >2;1;0)+If('STATUS 1'[t2s1q11] >2;1;0)+If('STATUS 1'[t2s1q12] >2;1;0)+if('STATUS 1'[t2s1q13] >2;1;0)+if('STATUS 1'[t2s1q14] >2;1;0)+if('STATUS 1'[t2s1q15] >2;1;0) >2;TRUE;FALSE)

It is an If function with multiple If functions within it: If(if + if + if ..) then, else - I am using it to measure If different test scores are above a certain limit (>2) and finally If >2 of these tests are above that limit. All the STATUS tables range from 1-5.

Is this possible in Power Query, as it is in DAX?

I'm fairly new to M, so this might be a newbie question. I would appreciate any help!


Finding First Name or Last name using DAX like @Username

$
0
0

Hi, 

I understand that PowerBI records name of all the users who are logged into the app. I am using RLS on  

I want to develop a greeting where I greet them with their name such as:

 

Good Afternoon Usman

 

Is it possible?

I found this solution but it doesn't work. 

 

Greeting1 = 
VAR user = USERNAME()
VAR display = LOOKUPVALUE(Table1[User],Table1[Email],user)
VAR hour = HOUR(NOW())
VAR minute = MINUTE(NOW())
VAR prefix = SWITCH(
                    TRUE(),
                    hour<12,"Good morning ",
                    hour>=12 && hour<17,"Good afternoon ",
                    "Good evening "
             )
RETURN CONCATENATE(prefix,display)

 


Re: Add timecolumn to another timecolumn

Re: Last n days regardless of year

$
0
0

Thank you, it seems that this will only mark the last 7 days of the current year, nothing in the past.

 

I am reading this article that kind of shows what I want regarding date vs day.
https://wmfexcel.com/2018/08/08/same-day-last-year/

 

Maybe compare last 7 days week number and weekday number with previous years, but how do you do that?

Re: Referenced Query and Caching question - explanation/confirmation required

$
0
0

I think the essential part of the article in reference to your problem is here:

However, because buffering happens in memory and is not persisted on disk, buffering during the load of one query does not affect the load of another query. If Q1 is buffered when Q2 is loaded, Q1 will be re-buffered when Q3 is loaded.

In other words if you load 14 tables loaded to your model there will be at least 14 calls to SQL Server. If you now have more (e.g. you reference the original table multiple times in ne query) then you can try using Table.Buffer()
https://docs.microsoft.com/en-us/powerquery-m/table-buffer

and change all the references within a particular query to the buffered table


disabling the background data preview should also reduce the number of queries during development time, as described here:

https://community.powerbi.com/t5/Desktop/What-is-doing-quot-Allow-Data-Preview-To-Download-In-The/td-p/345615

 

Index and match

$
0
0

Dear community members,

 

I am very new to power query and just made my first steps. Until now I've just created connections, filtered and sorted the data queries.

My question:

I have 3 tables and would like to add 5 columns to one of the tables called "order information".

Basically the columns I would like to add are information in a column in another table (activities: eg. 10 and 30 and record date). Also I would like to add the "category decription" in a column according to the category number. Table 2 (order information) has unique "order numbers".

If I would work on this tasks in excel, I would probably use index and match. But I would like to solve it in a more efficient way in power query. Any ideas and recommendations?

 

Thanks in advance!

Jan

 

Unbenannt.PNGclarification

Re: Power BI taking ages to apply query changes

$
0
0

Yes, everything will be in Power BI. I don't know DAX very well, though- how would I go about exploring it?

 

Thanks,

Jason

Viewing all 122482 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>