How can I limit the numbers of column in Matrix - sql

Unlike Tablix, I was not able to use limiting expression such as =ceiling(rownumber(nothing)/6) in Matrix.
Do you have any ideas to achieve limiting no. of columns in matrix- in design only, without touching dataset.
Or I should create it in Tablix?
Any suggestions please?

I think the only way you could achieve this would be to specify the column and row that you want your data to appear in from within your source dataset.
This could be achieved by taking a row_number and then doing integer division (<row_number value>/6) to get the row it should fall into and then modular division (<row_number value>%6) to get the column it should fall into.
From here you can build up your tablix grouping on your row and column fields.

Related

How can I generate a dynamic series in Power BI, for which the first value depends on a measure, and then plot on a visual?

Looking to generate a series of dates and values on Power BI for which the first value and the increments depend on measures. (Dynamic series generation and then applying to visuals).
Tried do to this through a calculated column, however this was unsuccessful as the column is calculated before the filtering on the measure can occur - so it was providing me with undesired results.
I have also tried to use GENERATESERIES within a measure with UNION to combine the date and values series. However, I am then unable to plot this on a visual as I have multiple values for my measure.
Any help would be greatly appreciated.
Cheers
GDB007
As long as you have a fixed X-axis, you can certainly define the Y-values dynamically using measures that are dynamic.
For example:
In this example, I just defined the [StartValue] measure as a constant 1 but it could be whatever you like. The [Increment] measure here just reads in the value of a small parameter table I created to show multiple values simultaneously by dropping that column in the Legend field of the visual, but this could also be whatever you like.

how to create a set based on a measure value in Tableau?

This is a very simple thing and I can't believe Tableau makes it so hard. I have a bunch of fields, and one measure has many zeroes. I just want to create a subset of the data where this measure > 0.
I can do it with a filter, but I since I will use it several times, it makes sense to create a set once and keep using it. Am I wrong to want to do that? Because I am finding it's just easier to just keep creating the filter in different sheets instead of trying to figure out the set.
I keep referring to this page, but they start out by telling you to right click on a dimension and create a set.
https://help.tableau.com/current/pro/desktop/en-us/sortgroup_sets_create.htm
I keep ending up here. What does it mean to apply a condition where the sum > 0? I want a set with any value > 0. That's not the same as a sum.
Actually your use case is not appropriate for sets. Sets in tableau work on IN/OUT principle. So the sets can be used as a T/F condition as well as used to differentiate the members IN and OUT of that set e.g. by differentiating these by colors.
What I can understand is that you just want to create a Calculating field which you can use as a ready filter as well as for differentiation also.
To illustrate let's take the following sample data
Now create a calculated field with the following calculation
[Measure] > 0
(Note- this would exclude negative values also. If your data set has negative values and you just want to exclude 0 values use <> instead.)
This calculated field will serve your purpose. See
and
Better seen with average
and
Good Luck.

Sum various subset of columns to get various subtotal columns

Would there be some handy way for summing various subsets of columns in order to get various subtotal columns?
Currently I have a query that calculates data to about 20 distinct fields. I would like to keep the data in these separate fields/columns,
but then I would like to sum various subsets of these fields to get various subtotals. And also the total of all fields to one new field as well.
I can only think of very laborious solution: adding a separate "sum"-column for each subset and doing a subset calculation totally from the scratch in each of these columns: (field1+field2+field2) AS Subset1, (field1+field2+field3+field4) AS subset2, etc. etc. (field1+field2+......+field20) as subsetTotalOfAllFields. Quite often the next subset builds on top of the previous subset, but as far as I know, at least with this approach, it is not possible to take advantage of previous subset total sum and just add the next column's value to already calculated sum.
Extra problem with the solution above is that in reality there's arithmetic calculation logic inside each original field, so I would not like to repeat those calculations again and again for each subset summing.
Anyone help?

Excel formula not working as expected

I have a sheet that shows max values spent anywhere. So I need to find most expensive place and return it's name. Like this:
Whole sheet.
Function.
Function in text:
=IFS((A6=MAX(D2:D31)),(INDEX(C2:C31,MATCH(A6,D2:D31,0))),(A6=MAX(H2:H31)),(INDEX(G2:G31,MATCH(A6,H2:H31,0))),(A6=MAX(K2:K31)),(INDEX(K2:K31,MATCH(A6,L2:L31,0))))
Basically I need to find a word left to value, matching A6 cell.
Thanks in advance.
Ok.. Overcomplicated!
Firstly, why the three rows? it's a lot easier if you just have one long row with all the data (tell me if you actually need 3 I'll change my solution)
=LOOKUP(MAX(D2:D31);D2:D31;C2:C31)
The MAX formula will lookup the biggest value in the list, the Lookup formula will then match it to the name.
Please note: If more than one object has the maximum price, it will only return the first one. The only way I can think of to bypass that would be to build a macro.
EDIT:
Alright.. Multi Column solution is ugly and requires extra columns that you can just hide.
As you can see you'll need 2 new columns that will find the highest for each row, 2 new columns that will find the value for each of these "highest" (in this case tree and blueberries) and then your visible answer will simply be an if statement finding out which one is bigger and giving the final verdict. This can be expanded with an infinite number of columns but increases complexity.
Here are the formulas:
MAX(H2:H31)
LOOKUP(A5;H2:H31;G2:G31)
MAX(L2:L31)
LOOKUP(C5;L2:L6;K2:K6)
IF(A5>C5;B5;D5)

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.