Filter records for Dropdown control - dropdown

How can I filter rows for my Dropdown control?
Currently I'm binding Items property to column e.g. Items=Table1.Name
but this populates dropdown with all possible rows. I want to filter all rows in which another column meets condition e.g. Table1.Date=Today()

You can use a Filter expression in the Items property of your dropdown control:
Items: Filter(Table1, Date = Today())
And you can select which field of your table to show in the dropdown by using the Advanced view (in the case below, Name, as you had in your example):

Just a note that I had to do something a little more complex for filtering out results for a SQL source where I also needed a Distinct.
The basic idea is I wanted years out of a table, but only last year and whatever years we had listed. Also worth noting the 500 row limit was a bit of an issue against my original date table, and so this only works with smaller tables.
In my case, I needed to create a view to reduce the data granularity
Distinct(Filter('[dbo].[YearList]', YearNumber >= Year(Now()) -1), YearNumber)

Related

Display proportion of data based on sum of a field

I have a problem with Tableau. In my worksheet I want to be able to use Sum(Field 1) to filter data I see on my sheet. So for example, If sum(sales)<20 only show the sales information which their sum is less than 20. When I try to create a calculated field to with the expression above Tableau converts it to a boolean filter instead of sliding my data to meet the filter criteria.
Is there any solution for the problem?
Thanks
you could filter the result using an having clause
select my_key, sum(field1)
from my_table
group by my_key
having sum(field1)<20

How to filter columns via MDX

Im new (couple of days to be exact) on Cubes, I have the following problem.
I have a Measure that brings certain amount of data, 100 rows for example. From that data I want to filter numbers that are < 0 from one of its columns.
For example this measure:
[Measures].[Distribution CSU Groups]
Will bring data like this
enter image description here
As you can see in the link, I want to filter those rows that have negative values on the 3rd column.
Is it possible to do this via MDX and how?
Yes filtering is possible in mdx via the following functions:
IIF function
FILTER function
HAVING clause

How can I create filter based on two different fields with OR operator between them in Power View?

For example I want to filter my data based on next filter expression:
lead_veh_of_interest starts with 'BMW 1'
OR
sale_model starts with 'BMW 1'
how can I achieve this?
Are these fields both in the same table? If so you could create a calculated column that performs that conditional. Then filter the view on the resulting calculated column.
For example you could create the following calculated column.
Calculated Column: "Starts With BMW 1"
Equation:
=IF(OR(Left([lead_veh_of_interest starts], 5) = "BMW 1", Left([sale_Model], 5) = "BMW 1"), 1, 0)
Then in the view set the filter so that [Starts With BMW 1] = 1
I found acceptable solution (thanks for all suggestions - it was very helpful).
First of all I redesigned my model and (how #Mike_Honey suggsts me) created dedicated table with consolidated information I want to filter. Next I connected this new table with existing tables and created hierarchy from fields I want to give to the end users for step-wise filtering (previously I split down old fields contained information I want to filter into more granular level). Now it is possible to filter data by any combination of models in any combination of request types (sale, lead, competitor, etc) using hierarchy.

Datatable Compute Method filter on row number

I use a query which fetches say 50 records and passes it to a datatable. This record is then displayed in a tabular format. The display has pagination used displaying 10 records at a time. There is a facility to move to next or previous set of record or move forward or backwards by 1 record.
I have to find Min and Max of a column for the set of record currently visible. I am planning to use Compute method but I am not sure if it allows filtering on anything other than the columns in datatable.
Do I have to include row number in my query or is there a better solution (something along the line mentioned below)?
CType(dtLineup.Compute("Min(ArrivalDate)", dt.row(2) to dt.row(12)), Date)
There is nothing like your pseudo code in MSDN on DataColumn.Expression. You could include a row number in your query, as you said, but an alternative is to add a row number column to your data table and use that in the filter expression.
DataColumn col = new DataColumn("rownumber", typeof(int));
col.AutoIncrement = true;
col.AutoIncrementSeed = 1;
datatable.Columns.Add(col);
Another alternative could be to do paging by linq (Skip-Take) and compute the aggregate function over the returned rows. But that may be a major departure of your current application structure.

How to make a drop down list (list box)in an MS Acess Query with values from two different tables

I need the drop down box above to display the date as shown and the ClassTypeDesc as you can see above the dropdown list shows 1/12/2010 twice. They have different ClassTypes Assigned to them.
The drop down list should show:
1/12/2010 ACLS-I Day One AM
1/12/2010 ACLS-I Day One PM
I need to know the statement to put in the Row Source Box on the lookup tab in the Field Properties to make this work.
Related Question on Making a drop down list
There's no need to concatenate the two columns. Based on the diagram, the SQL for your lookup combo box should look like this:
SELECT tblClassSession.SessionID, tblClassSession.Date, tblSessionType.ClassTypeDesc
FROM tblClassSession INNER JOIN tblSessionType
ON tblClassSession.SessionTypeID = tblSessionType.SessionTypeID;
Then in the properties for your lookup combo box, change ColumnCount to 3, and Column Widths to 0 (if you want to size the other columns, change Column Width sto something like 0";.75";1.5", and the List Width property to 2.25").
I may have gotten some of the field names wrong, but that's the basic idea.
(also, you probably really ought to rename tblClassSession.Date to tblClassSession.SessionDate so you don't run into problems with the fact that Date is a reserved word)
As you already have the right number of rows, you just need to concatenate enough fields to make it more useful, so your query would be something like:
SELECT c.Date + ' ' + s.ClassTypeDesc AS YourFieldName
FROM...