Filtering Filtered DataView - dataview

I have a DataSet which will be filtered twice like the following.
How can I set the RowFilter property of the DataView twice?
Or is there any other better implementation than the one below?
DataView dv = new DataView(myDataSet.Tables[0]);
dv.RowFilter = "approved = 1";
dv.Sort = "BookingDate";
foreach row{
//Filter by shiftTime in filtered DataView
foreach column{
//Find date in filtered DataView
}
}
Thank you in advance for your help.
Thanks,
artsylar

I don't know if you've already found the solution. I assume you have but I will still post a possible solution if it helps someone. It's in VB.NET though.
Dim dv_docs As New DataView(ds_allDocsInfo.Tables(0))
Dim rowFilter As String = ""
rowFilter = "DocumentStatus='Published' And templateFrameID='2'
dv_docs.RowFilter = rowFilter
DLDocument.DataSource = dv_docs
DLDocument.DataBind()
Note: To have multiple filters I have used 'And' and built a row filter separately before applying it to the DataView.
Hope this helps.

Related

Power Bi DAX - Calculating Workingdays from a past period

I´m really struggling about the following problem, searched a lot, tried a lot but still I´m not able to achieve my goal. I really hope, that someone can help me out with this.
Situation
I´ve created a meassure:
Measure =
VAR selYear = SELECTEDVALUE('Stats Param LindyCalendar'[Date].[Year])
VAR selMonth = SELECTEDVALUE('Stats Param LindyCalendar'[Month])
VAR selDay = day(now())
VAR enddate = DATE(selYear, selMonth, selDay)
VAR CurWorkingDay =
COUNTROWS(
FILTER(
FILTER('Stats Param LindyCalendar', 'Stats Param LindyCalendar'[Date].[Date] <= enddate),
'Stats Param LindyCalendar'[WorkingDay_YN] = -1))
RETURN CurWorkingDay
There are three slicers. The first one is based on Country-Table which has correct working relationships to all needed tables. It just filters the Country.
The second slicer is based on 'Stats Param LindyCalendar'[Date].[Year].
The last one is based on 'Stats Param LindyCalendar'[Date].[Month].
When I play around with the slicer, setting random values, it works fine.
Goal:
I want to get back the CurWorkingDay of the last year.
So I did:
VAR selYear = SELECTEDVALUE('Stats Param LindyCalendar'[Date].[Year])-1
The result is "Blank" in the Card-Visual.
That´s my problem, and I don´t know how to fix that.
Would be great if someone could provide a solution or hint.
Thanks a lot in advance.
Finally I got it.
workingdays_MTD =
VAR selYear = SELECTEDVALUE('Stats Param LindyCalendar'[Date].[Year])-1
VAR selMonth = SELECTEDVALUE('Stats Param LindyCalendar'[Month])
VAR selDay = day(now())
VAR enddate = DATE(selYear, selMonth, selDay)
VAR test =
TOTALMTD(COUNTROWS('Stats Param LindyCalendar'),'Stats Param LindyCalendar'[Date].[Date] = enddate,'Stats Param LindyCalendar'[WorkingDay_YN] =-1)
RETURN test
Power BI marks an error for "'Stats Param LindyCalendar'[Date].[Date] = enddate," but it works anyway...

In Power BI, how can you return the category label based on the max value for all categories returned by a measure using DAX?

Looking for some DAX guidance here, to return a text field based on the maximum returned by a measure appplied over that column.
i.e we have table[category_column] and [measure]
and the measure references columns in other tables, with two-sided relationships.
Any help much appreciated, very stuck!
Thanks in advance
If I'm reading right, I think you want to draw the measure against the column values and return the row with the max of the measure. Something like this?
newMeasure =
VAR vals = SUMMARIZE('Table', 'Table'[Column1], "myMeasure", [Measure])
VAR measureMax = MAXX(vals, [myMeasure])
VAR value = CALCULATE(MAXX(FILTER(vals, [myMeasure] = measureMax), [Column1]))
RETURN
value
If your column to be used for max is Column1 and your text field is Column2 something like the below could work:
Measure =
VAR Max_Value =max('Table'[Column1])
Return CALCULATE(MAX('Table'[column2]),'Table'[Column1]=Max_value)
If this is not what you are looking for you have to explain your requirements in further detail, hopefully with examples.

How can i transform measure value to text message conditionally in powerbi

I have a measure in a table:
Item Count = DISTINCTCOUNT(Shoes[Item Name])
I want to display a text message in a new column, just like in the example below:
SingleOrMultiItem = IF([Item Count]>1, "Multiple", "Single")
I have tried to use the IF in a measure, and a column, but it won't work. It is said that IF will not work in slice (in the context)
ideas?
Given your example you can try this next formula to obain your message in a new column:
NewColumn = IF(CALCULATE(SUMX(Shoes;Shoes[Item Count]))>1;"Multiple";"Single")
Please let me know if it works for you!

Sitecore Search Orderby

I am seeing a very strange behaviour from the Sitecore 7.1 Search when ordering by a string field. The code is something like this:
var indexableItem = new SitecoreIndexableItem(Sitecore.Context.Item);
var searchIndex = ContentSearchManager.GetIndex(indexableItem);
var context = searchIndex.CreateSearchContext();
var results = new List<Item>();
var count = 0;
var totalSearchResults = 0;
var contactColleagues = context.GetQueryable<SearchResultItem>()
.FirstOrDefault(x => x.ItemId == Sitecore.Context.Item.ID);
if (contactColleagues != null)
{
var items = contactColleagues.GetDescendants<ColleagueSearchResultItem>(context)
.Where(x => x.TemplateId == Templates.Colleague);
items = items.OrderBy(x => x.Surname);
var resultItems = items.Page(this.PageNumber, PageSize).GetResults();
}
This all works as expected and returns my dataset ordered by surname as expected. That is until a certainly individual comes along who's surname is "Or". Now Sitecore returns this persons name at the start of the list, no matter what we do.
After some testing I found the same issue happened if I decided to call someone "Andy And", this would appear at the being of the list before "Jeff Aardvark".
I'm assuming this is a bug in the way the data is being presented to the Lucene index.
Has anyone come across this, or have any thoughts about how this could be worked around?
Thanks in advance.
I think you have a problem with stop words. The default analyzer removes them when the item is crawled. You can however prevent this behaviour.
This post explains how to to turn off the stop words filter:
http://blog.horizontalintegration.com/2015/01/08/sitecore-standard-analyzer-turn-off-the-stop-words-filter/
If you look at the surname field in the index using Luke (https://code.google.com/p/luke/) is the value blank? It sounds like potentially dangerous query values are being stripped out either at the index level or as they are being loaded from the index.

Can I use the DynamoDB .NET Object Persistence Model when I have a Global Secondary Index?

I have a table in Dynamo with a hash & range index plus a secondary global index with just a hash. If I try to Query or Save an object I get the following error:
Number of hash keys on table TableName does not match number of hash keys on type ObjectModelType
(Replacing TableName and ObjectModelType with the actual table and model type)
I have the hash properties (both the primary and secondary) decorated with DynamoDBHashKey
Googling the error turns up exactly zero results
Update: Ok, so not exactly zero, obviously it now returns this question!
Update the second: I've tried using the helper API & it works just fine, so I am assuming at this point that the Object Persistence Model doesn't support Global Secondary Indexes
I encountered the same problem and found FromQuery worked, although QueryFilter is actually from the DocumentModel namespace:
var queryFilter = new QueryFilter(SecondaryIndexHashKeyColumn, QueryOperator.Equal, "xxxx");
queryFilter.AddCondition(SecondaryIndexRangeKeyColumn, QueryOperator.LessThan, DateTime.Today);
var items = context.FromQuery<MyItem>(new QueryOperationConfig { IndexName = SecondaryIndexName, Filter = queryFilter }).ToList();
Thank you Brendon for that tip! I was able to adapt it to get deserialization of a multiple result set.
var queryFilter = new QueryFilter(indexedColumnName, QueryOperator.Equal, targetValue);
Table table = Table.LoadTable(client, Configuration.Instance.DynamoTable);
var search = table.Query(new QueryOperationConfig { IndexName = indexName, Filter = queryFilter });
List<MyObject> objects = new List<MyObject>();
List<Document> documentSet = new List<Document>();
do
{
documentSet = search.GetNextSetAsync().Result;
foreach (var document in documentSet)
{
var record = JsonConvert.DeserializeObject<MyObject>(document.ToJson());
objects .Add(record);
}
} while (!search.IsDone);
Thanks x1000!! :)