missing data in tableau - sql

When I exclude the first column (2017) the data in the second which is now first (2018) goes missing as well.

It looks like you are using a Table Calculation of Percent Difference From If this is the case, the first column will always be blank when set to Table (across).

This is a case where you want to hide the first column, not exclude it. That way Tableau includes the first year in its query and calculations, so that it can then compute the percentage differences client-side in a table calc.
Just right-click on the first column header, and choose hide. The data will be there behind the scenes to support the calculations, but not displayed.

Related

Visualizing last refresh date in power bi

Is it possible to add a card in power BI that shows the last time the underneath dataset has been updated?
Many thanks!
You can create a blank query and use the following M query to create a single-cell table:
let
Source = #table(type table[Last Refresh=datetime], {{DateTime.LocalNow()}})
in
Source
And then you can use the Card visual and drag in the column to show it. You can rename the field to remove the default aggregation. (It doesn't matter since there is only one row of data anyways)
The value will be recalculated each time the data is refreshed.
you can achieve this by adding a calculated column (Refresh data Column) in the model with the formula =NOW()
Then add measure
Last Refresh Date :=MAX(Table[Last Refresh Column])
Since calculated columns are calculated only on model refresh - it will make sure the calculation is right.
The below code is working for me (for HK).
Add a column with the below formula
Last Refresh = FORMAT(UTCNOW()+TIME(8,0,0),"dd MMMM YYYY ttttt")
Depending on the location it's really confusing with all those functions..
Let me suggest you the workable one:
Go to the:
Query Editor
1.right click on the Queries body on the left side
2.new queries
3.Blank Queries
4.Paste the following formula by putting the right Server Instances and DB Name,
" = Sql.Database("Server\Instance", "Database", [Query="select GETDATE() LastRefreshDate from AnyTableName"])
It'll work out. And since it's pulling directly from the server,, you don't have to worry about choosing the right DateTimeZone functions in PowerBI.

Crystal Reports crosstable formatting

My colleague and I have taken over a vb.net project that uses Crystal Reports (I have CR9 on my PC).
The user has given the following feedback to us on how he would like the reports changed.
1) At the moment, it is wasting space by showing empty columns. How is it possible to not show the columns where all values are "-"? (I've tried using Crosstab Expert, however there are some reports where the columns have second sub-columns with titles in, so with these ones it shows them as it treats the columns as not empty)
2) The crosstabs at the moment are displaying from left to right, and are adding next to each other. My user wants the tables to go underneath each other, so that the report goes downwards, rather than sideways. How is this possible?
If anybody knows a fix to either of these issues that would be great, thanks.
In regards to the empty columns, you can choose a custom style in the Crosstab Expert and select Suppress Empty Columns
If the dashes don't count as empty, you might need to change the crosstab to evaluate a formula which replaces the dashes as zeroes or blanks.
I'm not aware of a good way to make a crosstab separate vertically as you specified. But you could swap the rows with the columns. It appears to me you have way more columns than you do rows, which should fit better on the page.
I suppose you are using the database field directly in the cross tab which is the reason you are getting -. Possible approach would be to write a condition and use that in cross tab. something like below
Create a formula #Formula1
if {Database.field}<>"-"
then {Database.field} //You can end the condition here if you wish
else "" // If you write else then check option supress empty rows or columns as per requirement
Now create a cross tab using Formula1 and display
Coming to your second problem , If you not wish to spread cross tab horizontally then you can pivote cross tab by Right click on cross tab or go to cross tab expert and give the fields that spread in rows part and that are static in column part.
Hope this helps

Customize the last three rows of a Tablix in SSRS

I have a table which is getting data from a query. Because I am not doing any calculation in SSRS, but instead in SQL and only pulling the data, I am having hard time figuring out how to customize the style for the last three rows.
Here is the design view:
Here is the preview:
Now as you can see the last three rows are either SUM or AVG of the above numbers. How can I make it so that the table displays a different background color for the bottom three rows?
You will need to add an expression for the text box format for the three rows that says something like:
=IIF(Fields![ARRIVED_DATE].Value="WEEKLY TOTAL","Grey",IIF(Fields![ARRIVED_DATE].Value="Prior Week","Red",IIF(Fields![ARRIVED_DATE].Value="12 WEEK AVERAGE","Green","Transparent")))
If i understand your point correctly this would be the solution =iif(total number of records(int)=rownumber(nothing), "Color1",iif(total number of records(int)-1=rownumber(nothing),"Color2",iif(total number of records(int)-2=rownumber(nothing),"Color3",""))) use this expression in Background color of row properties.

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

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:

How to specify an order for the columns in a matrix?

I'm working on a SQL Reporting Services report (in VS.Net 2005) which displays a count of different data in a matrix. The columns have a count on the amount of customers in a certain set. So I have several columns like these: "1 employer", "2-9 employers", "10-19 employers" and so on.
The problem I have is that SQL Reporting Services sorts the columns in the matrix alphabetically. So I end up having the "10-19" column after the "1 employer" column but before the "2-9".
Is there any way to fix this?
Or maybe a trick to change the labels of the columns to that they sort right?
Thanks.
This can also be done by adding a new column to the query for the sort order. Then right click the column group from the matrix and select group properties. On the left hand side select sorting. From here you can specify another column to sort by instead of the column header. No custom formula needed.
We do a lot of SSRS Reports and this was always an issue with mdx. Here is one way we do it:
Set Sorting in the Grouping and Sorting Properties to sort by this expression:
=iif(Fields!DataSetField.Value = "ColumnName", "zzz", Fields!DataSetField.Value)
Where "zzz" could be a number or whatever you need it to be to help the sort and then select Direction as either Ascending or Descending base on this expression.
This may be a bit convoluted, but we had a similar problem and no means to change the SQL.
What we did was create a calculated field in the dataset that returns a number for each column and sorted the group on that number.
I had a similar problem but did not find a solution using a matrix in time - so I used a table - and put the needed logic of the matrix in my SQL-statements.
It's not the best thing to do but it works - it's fast enough and it don't takes that long to write.
I went into MATRIX --> PROPERTIES --> GROUPS.
Then, I "moved" the GROUP I wanted it to sort by UP in the list.
I went to PREVIEW, and it worked perfectly.
It even kept my column order the same.
Go to Edit Group - Sorting - Change the direction to descending for the expression.
For distinct numeric order of a Tablix use following line of code in expression.
=RunningValue(CountDistinct("YourTableName"),Count,"YourTableName")
Simply Go to tablix/Matrix Column Group and Right Click on the Group Properties then go Sorting and Delete the auto added record from Sorting.. Now your sorting will based on the Data you have added in Data set.