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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
stuarthokie
Frequent Visitor

Native Query to Pivot Large Volumes of Data

Hello!  I have a challenge for which I have not seen a resolution posted.  I have seen similar issues resolved, but none like what seems to be my normal challenge.  I am green to the more complex workings of PBI and am therefore seeking help.

 

I would like to pivot my data.  But I have restrictions that make it so column pivoting is off of the table as an option for resolution.  If possible, I would like this to occur in the Native Query.  This seems to be the best option but please correct me if I am wrong.

 

DATA TABLE EXAMPLE:

The "PLC Tag" names are in the same column, this is a problem

Time StampPLC TagValue
5/3/24 2:51Tag15.00
5/3/24 2:51Tag210.02
5/3/24 2:51Tag315.03
5/3/24 2:52Tag120.05
5/3/24 2:52Tag225.07
5/3/24 2:52Tag330.08
5/3/24 2:53Tag135.10
5/3/24 2:53Tag240.12
5/3/24 2:53Tag345.13
5/3/24 2:54Tag150.15
5/3/24 2:54Tag255.17
5/3/24 2:54Tag360.18
5/3/24 2:55Tag165.20
5/3/24 2:55Tag270.22
5/3/24 2:55Tag375.23
5/3/24 2:56Tag180.25
5/3/24 2:56Tag285.27
5/3/24 2:56Tag390.28
5/3/24 2:57Tag195.30
5/3/24 2:57Tag2100.32
5/3/24 2:57Tag3105.33
5/3/24 2:58Tag1110.35
5/3/24 2:58Tag2115.37
5/3/24 2:58Tag3120.38

 

DESIRED OUTPUT EXAMPLE:

1: The "PLC Tag" names become the headers of different columns for each unique "PLC Tag" (NOTE: there will be MANY more than 3 in this example)
2: Each row is defined by each unique Time Stamp (yes, the various tags' data have identical time stamps and are minute data)
3: The Values are placed in the proper "PLC Tag" and "Time Stamp" intersection

Time StampTag1Tag2Tag3
5/3/24 2:515.0010.0215.03
5/3/24 2:5220.0525.0730.08
5/3/24 2:5335.1040.1245.13
5/3/24 2:5450.1555.1760.18
5/3/24 2:5565.2070.2275.23
5/3/24 2:5680.2585.2790.28
5/3/24 2:5795.30100.32105.33
5/3/24 2:58110.35115.37120.38

NOTE: I believe achieving this using a Native, Folded Query is the goal due to processing concerns. Pivoting the data on the back end is a non-workable option due to tens of millions of rows of data and counting. Pivoting either crashes my machine or takes several hours to refresh if successfull. The data are so many that Incremental Refreshing will also be employed each day, multiple times per day, as the data table grows.

 

NOTE: Achieving this is NOT how it will end up looking in the visual; this is only step 1: desired organization of data. There will be MANY new columns of calculated metrics created that will have somewhat complicated expressions incorporating one, some, or MANY of the "PLC Tags'" values.

 

 

12 REPLIES 12
lbendlin
Super User
Super User

Your data is already in the perfect format for ingestion. Resist the urge to mess with it, and do all your pivoting in the visuals.

Thx, Ibendlin!  The desired result shown is not at all what my visuals will look like, only what the resulting table will look like.  In fact, there are exactly zero items from either the original or the resulting table that will be a part of the visuals: no time stamps, no "Tag Names", no values.

 

This challenge is to get the data in a desired format in order to reduce processing on the back end so that I may add many new columns of calculated metrics created that will have somewhat complicated expressions incorporating one, some, or MANY of the "PLC Tags'" values.  It is these new calculated metrics which will be shown in the visuals.

Put your data into a matrix table, then examine the DAX query that Power BI creates for that (including filters).  Use that query as the basis for your measure calculations.

Hello, Ibendlin!

 

I'm not sure what I was supposed to see but there is nothing helpful in this code from the matrix table:

EVALUATE
    TOPN(100, 'DataTable')

Use Performance Analyzer on the Matrix visual. Copy the query and examine it.

There is no query to copy which makes sense.  All I am doing is selecting rows, columns, and values to place in the Matrix:

stuarthokie_0-1726233739364.png

That's not all you are doing.  You are also applying filters.

 

Click Start Recording, Refresh Visuals, Copy Query.

I did not refresh visuals previously, thanks!  I'll disect this code when I have time and get back to the thread.

Anonymous
Not applicable

Hi @stuarthokie ,

Did your problem get solved? If so, please mark lbendlin 's answer as the solution.

 

Best Regards,
Wenbin Zhou

As promised, I have finallly found a solution.  It has nothing to do with what can be done in PBI.  Due to the large volumes of data, everything I tried to do to pivot the data failed in the PBI environent.  I had to resort to creating an entirely new table view in the data synapse.  Sorry this won't help anyone else out other than not wasting time trying to pivot large volumes of data in PBI.  Best case scenario, it was able to complete the pivot (albeit a couple of months ago, when there were far fewer data than now and, indeed, vastly fewer than there will be 10 years from now) in 3h ONLY ONCE.  All other times, crash and burn.

Hello!  No, not solved, still working on it.  If I am able to come up with the solution, I will post it here for others.

OK, thanks!  Will give it a go and get back to the thread.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.