In this dataset I am trying to develop a column or a measure based upon the hours column. I am trying to determine the difference between the first and second hour rows, the second and third hour rows, etc. and all the way through the entirety of the data.
Note: there are multiple serial numbers in this table; I just used this serial as an example.
I'm not sure this should be tagged with SQL-Server unless you can change the SQL that sources the data. If so you could pre-calculate this inside SQL Server.
If you can change the Power Query that brings the data into the data model you can add an Index column as the data's coming in and use that.
Please see:
How to Compare the Current Row to the Previous Row Using DAX
Related
I'm bringing into SQL Server 2012 an external db table which has about 2 million rows and a Comments field nvarchar(200).
1st step moves data into a Staging DB.
2nd step move data into a Data Warehouse, incremental load once a day will be about 10,000 rows.
When moving data to DW I want to also split out the numeric data from Comments field into a new column.
I'm thinking of using TRY_CONVERT(FLOAT,col) but want to know if this is best function performance wise to use or another way.
Guessing best to do this with sql rather than in SSIS with an expression derived column?
I don't have access to system yet to test but thinking this over to plan.
I am using report builder to create a report showing a budget for a project. The dataset includes line items for both budget and projected. See below for example rows. I am using a matrix with column group to display budget and projected side by side as well as a row group to show section, category, etc. I need to have a variance column that subtracts projected from budget.
I have scoured the interwebs for solutions but nothing that has worked so far. I feel like there has to be simple solution to this given it is something that could be done in a sql query with zero effort. Most solutions are assuming I have two separate fields, but these are dynamic fields pull out with the column group.
Dataset Row Samples
Type Section Cateogry Phase Task Total
Budget Building Kitchen Pre-Construction Cabinet Hardware $100
Projected Building Kitchen Pre-Construction Cabinet Hardware $220
Report sample
COL GROUP This is the column i want
Budget Projected Variance
+Buidling $100 $220 -$120
+Kitchen
+Pre-Con
EDIT: I tried the below solution without success and have already visited every link provided in the second answer. Maybe there is something I am missing, but I ended up just doing everything in the SQL query and not use Column groups. This is 100% the simplest solution. I am very surprised there is no easy way to reference individual columns in a column group. The below may work for others, but I just could not get them to work for me. Not sure why.
You could add an additional column inside the “Type” group (provided that this is the name of your column group). Set the Column Visibility to hide the column by an expression like
= IsNothing(Previous(Field!Type.Value, “Type”)
Calculate the values for that column as
= Previous(Sum(Fields!Total.Value), “Type”) – Sum(Fields!Total.Value)
That should calculate the difference between the values of the previous type and the current type, and
only show that column for the "Projected" type (when there is a previous type).
On the matrix, you can use the group subtotals to achieve this, you only have to overwrite the SUM operation with an expression that subtract to values. There are many link mentioning how to do that or that can helps you:
How to add calculated column from dynamic columns to a matrix
Adding subtotals to SSRS report tablix
How to write Expression to subtract row Group SubTotals
Reporting in SQL Server – Using calculated Expressions within reports
I have a workbook in which a variable number of rows of data (one per employee) are entered each week on one sheet (DATA ENTRY), and then stored on another sheet (LOG) with the help of a macro that is executed every time the file is saved.
To be able to then retrieve and review employee data for a specific week, I need a column of helper cells in which all the unique distinct dates (weeks) are listed.
I currently do this with the following array formula:
{=IFERROR(INDEX($B$2:$B$1600, MATCH(0,COUNTIF($K$1:K1, $B$2:$B$1600), 0)),"")}
This all works brilliantly, except that I found that this one specific formula slows my file down tremendously. When the file is saved (which triggers data to be copied over to the LOG sheet), it can take up to 10 seconds to process. When this array formula is disabled, it is pretty much instantaneous.
Limiting it to run over 1600 rows helped significantly (it took much longer before when I had it set to 20.000), but it is still not enough and I can't really have this check less than 1600 rows.
Any creative solutions to either make this formula run faster, or to get to the same result (a list of unique distinct dates from a large list of dates) without using an array formula?
Thanks!
You could use Power Query (Get & Transform Data) to populate your list of unique dates.
I'm trying to make an SQL Query output more readable for our staff. It is a kind of a Warehouse Delivery note. Does not matter if I use Word or Excel or something else.
So I made an SQL Query (MS-SQL 2000 Server), this is working fine. The output obviously is a Table. The first 7 columns containing data that needs to be one time on the print as heading. The next columns containing data that needs to be on a list on the print. Already used PowerPivot to put it in Excel.
To make it some clearer I made a pictures in Excel. The data in the first column contains a "warehouse" number. I need a separate print per Warehouse. As you see, the first 7 columns also containing data concerning the warehouse. The last 3 columns are the products.
I have to put this:
into this, were Column 1 contains the same value. Other value of Column 1 goes to the next page and so on:
Return 2 datasets into your excel workbook, one for the heading values and the other for the details. I'm assuming your first dataset should only return the one row, which means you can reference the values in the data table directly without issue.
Your second table can then be directly inserted into the details section of your spreadsheet and formatted accordingly.
Well, so far it is working now. I used the Grouped Serial Letter function in Word from one Excel Table only. I tried the two Excel table Database Serial Letter version also, but somehow it did not worked. And what did not worked? I dont know, when I run the Database version I only get gibberish output and Errors.
So now I have it that way, that I run a SQL Query, that gives me one Excel Table. After that I run Word and print a Serial Letter
I'm attempting to create a MS Query to return data from a SQL database based on a value from a cell in Excel. I have actually successful accomplished this, but only for 1 row. I cant figure out how to get it to copy-down to other rows.
I've created a connection as follows:
Notice that the SQL statement includes a parameter. The parameter is set to point to a specific cell:
I guess this makes sense as I'm only looking to return 1 value per row:The problem is that I have multiple lines to return values for. How do I return a value per row for multiple rows?
I've tried changing the cell reference in the Parameters dialog box, but this does not work as the Excel Table is designed to grow dynamically.
Excel data connections works in a way that every connection has only one SQL Query. So in order to do what you'r looking for, you will need to have many connections, and that's not the "best practice".
However, there are two ways you can solve this situation:
1. Make a single connection with all of the data and create a pivot table based on it. Then use VLOOKUP/INDEX to gather the data to your requested cells.
2. If the data is too big, you can use VBA code to create a smaller Query based on the cells you mentioned and then continue as described on the first option.
Good luck.