Reporting Services - Two filters on the same chart Category Group? - sql

I have sales data that I'd like to plot on my chart. However, at a specific point in time, we had a change taking place I'd like to ensure is clearly visible in the chart, preferably by dividing the sales data (which is stored in a single SQL Server column) into two different chunks, which would allow me to then treat them as different data series.
I used to solve this in Excel by storing the post-event data in a different column (by simply dragging them to a different column), and thus I was able to treat them as a different series (the blue and green line in the chart below. The red and orange line are pre-event and post-event averages):
I'd like to reproduce this effect in SSRS, but am not sure how to tackle it. I've tried using an approach where I added two category groups, both pointing to the date-time column, and applying filters to them (one <= the cutoff date, the other >=).
I then added my sales data twice, with the idea I could somehow connect them to the individual category groups, but that does not seem possible.
Has anyone tried anything like this before, or would have a different approach to achieve what I'm trying to get?
Thanks!

I managed to get this to work, and figured I'd share how to do it.
My dataset contains a field called DATEKEY, which stores the date in the format YYYYMMDD. It's possible to use this in an expression and evaluate the date for a specific row. In case the expression evaluates to true, we display the value. If not, we display a blank string.
In case we want to show the values prior to the date, the expression would be:
=IIF(Fields!DATEKEY.Value <= 20130601, Avg(Fields!My_NUMBER.Value), "")
The second series can then be made by reversing the symbol:
=IIF(Fields!DATEKEY.Value >= 20130601, Avg(Fields!My_NUMBER.Value), "")
The graph then looks like this:

Related

Bigquery Regexp pull from 2 different patterns

I'm trying to pull product search colors from urls in my bigquery data, but the urls format changed at one point so I'm trying to pull them from two different formats.
The first one is like /someproduct/color/blue/color/red and the second one is like /someproduct/?colors=blue,red.
In both these examples, the person filtered on multiple colors, and I would like it the output of the extraction to be like 'blue,red' and all in one column.
I can pull the first one with:
REGEXP_EXTRACT_all(url,r'color/([A-Za-z]+)')
and the second one with:
REGEXP_EXTRACT(url,r'colors=(\w*,\w*)')
The first one produces an array and I don't know how to get all the outputs to show as one line item in one row. A person can filter up to 20 colors, so there can be a lot of repeating within both of the URL types.
The second one also can use some improving as I have to add in an additional \w*, for each additional color filtered on, and I have a case statement that handles that, but I don't think it's the most efficient way to handle it.
Consider below approach
select url,
coalesce(regexp_extract(url, r'colors=(\w*,\w*)'), array_to_string(regexp_extract_all(url,r'color/([A-Za-z]+)'), ',')) colors
from your_table
if applied to sample data in your question - output is

Dynamically creating a pivot table using fuzzy matching

So, I'm constantly being given data in new and different formats. I'm on a crusade to get my work to standardize data for easy use, and if I managed to convince the powers that be to standardize data, this problem becomes entirely moot. Until then, I have the following problem:
I get data in a variety of ways. Sometimes my gross sales are called total sales. Sometimes gross sales before discounts, total sales before discounts, Gross_Sales, etc. Discounts, deductions, exempt amounts, etc. form another column. So on and so forth. I'd like to be able to do the following:
1) Figure out what columns I want,
2) Turn those columns into a pivot table.
For part 1, I have two options, and I'm wondering if there's anymore: The 1st is to use Microsoft's fuzzy-matching add-in to help me match. I'd have a separate tab dedicated to fuzzy matching each column I need. The second is to just generate a long list of all the variants, and to test each one until I find a hit, assign it, and move onto testing the next one.
The second part is turning all of this into a pivot table - the resouces I have so far are https://www.thespreadsheetguru.com/blog/2014/9/27/vba-guide-excel-pivot-tables and How to Create a Pivot Table in VBA
Is there a better method? Is there another way?
Edit: Slightly better method - Grab the data columns, place them into a table, and pivot everything off of that table - it removes the need to re-create pivot tables, just need to move the data over.
Having the same problem, I use a mix of your two methods.
My data consists of a bunch of logs for rejected x-ray images, and the reject reason is a free text field. My solution was to create a table where the first column contains my desired output categories, and then each subsequent column contains a different variation of it.
For example, a row might have (column one/ouput first entry):
Positioning, POS, Positioning Error, Patient Positioning
Note that these are all fairly different from each other. Where the fuzzy matching comes in - it is used to capture all the smaller differences and mispellings around those other columns. When the fuzzy matching section decides a given reason matches a column's entry, it is then replaced with the appropriate desired output reason from column 1 of the table. In my example, a reason of 'Possitioning Err' [sic] would match to column 3 (Positioning Error) and then get converted to Positioning.
Then wash rinse repeat over the rest of your data as needed. This approach was super useful and fairly flexible in helping standardize my data. It was also computationally more expensive, but you'd only need to run the matching portion once I guess.
As for the actual mechanics of going about doing this - I use 2010, so no inbuilt functionality. I run the fuzzy matching code on a temporary worksheet until best percentage matches are found, and then overwrite the actual source data afterwards.

PowerBI Dynamic Time Series BarChart

Adding on my previous question here: TimeSeries question
I would like to plot a unit capacity chart over a Time series (which contains a range of dates set by the user).
The chart I am trying to plot is as follows:
For each Unit Name, I have start and end date for the unit capacities, as shown in the PowerBI table as below:
4 sub questions:
How to plot these capacities over time? Maybe using some DAX functions?
Do i need the SSAS cube to solve this problem or can I do all the work inside PowerBI desktop? If not, is there a better way for example in SSRS?
Is there a way to make the x-axis time series dynamic as specified by the user?
Adding to this, after Leonard's response. After converting the OutageStartDateOrig, and OutageEndDateOrig values I tried to create the calculated column as suggested in the youtube link {enter link description here}. However, the DAX formula as shown in the video gives out a syntax error for me stating that the '.' is incorrect when specifying the range of dates. Any ideas for this? [Screenshot below]:
To create such a visual, I'd recommend an area chart (or stacked area chart) with the date on the axis, the unit name on the legend, and the capacity on the values. You could also do it as a stacked column chart too. However, then each date will be broken into discrete columns. See below image.
In terms of data manipulation, you'll need to convert the data with the date ranges you have above into a row for each individual date & unit. E.g. the first row, instead of being 11/2 to 13/2, would be expanded into 3 rows, one for each date.
You can do this in Power Query as you bring the data into Power BI Desktop, or in DAX after bringing it in. There are several solutions to this outlined in this thread (https://community.powerbi.com/t5/Desktop/Convert-date-ranges-into-list-of-dates/td-p/129418), but personally, I recommend the technique (and video) posted by MarcelBeug (https://youtu.be/QSXzhb-EwHM).
You'll also want an independent list of dates (with no gaps) to join the final date column to - otherwise your visual will skip dates when no units had capacity. By default, the chart will begin on the first date with data and end on the last date with data, so in that sense it is dynamic, but you can add a date slicer to give the end-user more control.
Area chart on top, column chart on bottom, date slicer on right filtering Jan-Mar.

Im trying to populate a Sharepoint list with the most upcoming dates from certain colums of data from another Sharepoint list?

I have a list named Employee Dates, this list contains the columns:
Employee | CPR Completed | CPR Required | ETC
These columns keep going on for all of the training courses required for our employees with alternating columns for completed and required dates. I am using a workflow to calculate all of the required dates of training from the completed dates.
What I desire to do is make another list that will look at ALL of the columns for the required dates and find the soonest ones and populate that list with the soonest dates and from which column it was pulled from.
Any help as to how to approach this? I have been trying to use queries in Access and also some of the custom view settings in SharePoint Designer but no luck so far.
You could try an Excel table (they also have these functions in access if I recall, but I avoid access like a plague). To connect Excel to share point follow the steps in this article:
support.office.com
Ok, now that we are connected you should see all of the columns and values in excel. Next up we need to find the min date (easy) and then get the associated column name (a little harder).
Min Date: The formula should be something along the lines of =min(B1,B3,B5), jut type in =Min( and then CTRL-click on the columns you want to consider for the row. When your done close with ). After wards double click on the square in the bottom right corner and it will do the same logic for all of the rows.
Column Name: A little more difficult, use the min value from the prior column as the lookup value for VlookUp to get the column name. After wards double click on the square in the bottom right corner and it will do the same logic for all of the rows. I'd explain VlookUp, but I'd run out of characters and attention span long before I got to the relevant parts, and excel functions does a fine job of getting you the basics.
Anyway hope that helps,

Qlikview Expression to get Average in comparison to selected criteria for Chart

I am trying to create a chart that displays the average of a parameter of an entire category. The problem is that in sheet 1,2,3,4, etc, the charts I have reflect one parameter, so when I go to compare this parameter to the average in my new sheet, I only get the average of the fields that have been selected in prior sheets. I want it so that I can create a new chart with one bar as an average of the entire population, and another bar in the same chart that depicts the average of the selected parameter(s). Ideally, I would have two dimensions/x axis categories, one for the selected criteria, and one for average of all categories. Can someone help?
Thanks.
I believe the way to handle this is with set analysis. You can create one expression with the normal avg(parameter) and another expression with some embedded set analysis. See example below.
Expression1: avg(parameter) // will agregate everything in the current selection
Expression2: avg({1<category='YourCategory'>}parameter) // will aggregate everything in a category that you set in the set analysis syntax.
With some more specific info I would be able to get you an actual expression, but hopefully this helps.
EDIT
Updated to reflect new information provided in the comments.
Expression1: avg(parameter)
Expression2: avg({1}parameter)
In set analysis syntax the {1} means the entire universe of data where as {$} is your current selection. In other words, 1 is your data with nothing selected. In my first example above, the {1<category='YourCategory'>} statement uses a modifier signified by the <> so that you would be performing the aggregation over the entire universe with only the value specified in YourCategory selected.
So if the scenario is that you have currently selected let's say, 5 zip codes, your current selection ({$}) would be those 5 zip codes and the entire universe ({1}) will be as if you selected no zip codes. Therefore comparing those two populations side-by-side in two Expressions should give you the comparison you want.
Caveat: Using the {1} syntax in your expression means that your average of "all zip codes" will always be the average with nothing selected unless you put something in the modifier as in my first example. See this more detailed explanation.