concatenation of two measures in mdx query result - mdx

is it possible to concatenate two measures values into one cell ?
this is the sample query but it doesnt work:
WITH member [Measures].[tmp] as ([Measures].[m1] + " " + [Measures].[m2])
SELECT {[Brand].[Brand Name].[Brand Name]} ON ROWS, {[Measures].[tmp]} ON COLUMNS FROM [DEVEL]
thank You very much for any help

Perhaps you need to make it clear you are after the .Value of the member, otherwise the MDX parser thinks you mean the member (object) itself?
WITH MEMBER [Measures].[tmp] AS '[Measures].[m1].Value & " " & [Measures].[m2].Value'
I've also tweaked the syntax a bit: I think you need & to concatenate (like VBA, which MDX understands if using MS OLAP), and you should need single quotes around the definition after the AS.
Alternatively, if you are using your own code to call MDX, then you can read the cell values yourself, and concatenate anything you want before displaying it?

Related

DLookup returning True for some values, and False for others

I am writing a program, and I need to be able to check whether a certain 'tag' exists, by looking at all the 'tags' in the column 'CowTagMain' of the 'CowTable' table.
The code I am using is,
DLookup("[CowTagMain]", "[CowTable]", "[CowTagMain]") = Tag ...
Where tag is a String, TagMain is the column, and MainTable, is the table I am fetching data from.
I am getting inconsistent results, when I try this with 18C, it returns true. While if I try this with 18, it returns false.
I would assume I am fundamentally misunderstanding how to use DLookup, but after searching the internet for hours I cannot understand what I am doing wrong.
Even just pointing me in the right direction would be very appreciated! I am new to working with Access and VBA.
The search criteria is not within the function WHERE CONDITION argument.
The field is text type so need apostrophe delimiters.
Consider:
If IsNull(DLookup("[CowTagMain]", "[CowTable]", "[CowTagMain]= '" & Tag & "'")) Then

Filtering subform by date field

Still a new learner here so please excuse my formatting.
1. I'm trying to figure out how to filter my subform[frmSelectorquerysub] based on a date range on my parent form[Results Form].
I know it can be done in VBA, that doesn't mean I know how to do it, but I want to try to use master/child fields. I've used master/child fields to filter my subform by combobox selections and I've even got it to do three filters at once off of them.
Is it possible to use this method to filter date?
I've included my (compacted/repaired) db for an example.
Please excuse the messiness.
https://drive.google.com/open?id=0B7Uh_goO6l7QSmdPLXVqQlpiQVE
2. If it's not possible to use this method I would use BETWEEN for the range, right? How about the others where they are just single values?
3. If we can get this to work this way, would someone also be able to help me fix my syntax on my master/child fields so I don't have to set all three filters that they have right now to get results?
MasterLinkFields and ChildLinkFields are for one or more fields only.
But you can set a filter on the subform:
Dim Filter As String
Filter = "[DateFieldInSubform] Between #" & Format(Me!StartDate.Value, "yyyy\/mm\/dd") & "# And #" & Format(Me!EndDate.Value, "yyyy\/mm\/dd") & "#"
Me!NameOfSubformControl.Form.Filter = Filter
Me!NameOfSubformControl.Form.FilterOn = True

Microsoft Access search query

I have a search query that compare the text from text box with my database table untill now I have no problem and every thing works good .. but when I want to make the query compare part of text with database here I have the problem. For example if I have record "USA". I want to type "us" in the text box the query must have a result "USA".
Here is my query:
SELECT Goods.ID, Goods.Name, Goods.Description,
Goods.CatID, Goods.SubCatId, Goods.DealerPrice,
Goods.SuperDealerPrice, Goods.EndUserPrice,
Goods.BarCode, Goods.Quantity
FROM Goods
WHERE (((Goods.CatID)=Forms!Form1!Text58)
And ((Forms!Form1!Text78) Is Null))
Or (((Goods.SubCatId)=Forms!Form1!Text78))
Or (((Goods.BarCode)=Forms!Form1!Text115))
Or (((Goods.Name)= Forms!Form1!Text115))
Or ((Goods.Description) Like [Forms]![Form1]![Text115]);
I know in sql I must to put "%" in the query but it's not work.
Can any one show me how to make the change on this code here and I will make the others:
((Goods.Description) Like [Forms]![Form1]![Text115]);
Use * in Access.
((Goods.Description) Like "*" & [Forms]![Form1]![Text115] & "*")
Or you can use alike if you plan to use %.
((Goods.Description) alike "%" & [Forms]![Form1]![Text115] & "%")

how can I disable rows in my gridview with datasource rowfilter?

How can I hide rows in my Gridview with a specific value? For example I want to hide all rows with column("dubletten_Vorschlaege") is empty
skmTabelle.SLXADRIUMDEVDataSet.Tables("SKM2").DefaultView.RowFilter = "Dubletten_Vorschlaege =Nothing"
said he cant find the column nothing?
skmTabelle.SLXADRIUMDEVDataSet.Tables("SKM2").DefaultView.RowFilter = "Dubletten_Vorschlaege ="""
said he cannot read the statement at """
I've never used rowfilter so I hope someone can explain.
Edit:
thx levi, it doesn't throw an exception now. But the gridview doesn't change. how do I do that? Do I need to use the fill query again?
on the formload event I have
Me.SKM2TableAdapter.Fillg(Me.SLXADRIUMDEVDataSet.SKM2, Module1.pkey)
which only selects the rows which are new.
for example I imported new 2000 rows it only shows them.
Do I need to use this statement again?
I would refer you to this site for a few tips on using rowfilter.
http://www.csharp-examples.net/dataview-rowfilter/
In your case, I think the proper way may be to write the string like this. I have followed a similar approach and this worked.
...DefaultView.RowFilter = "Dubletten_Vorschlaege ='" & "'"
you will notice that i add a single quote after the = and again add a single quote within double quotes after the &.
Also, I refer you to this StackOverflow link
How do I check for blank in DataView.RowFilter
The user simply added the line of code as this:
...DefaultView.RowFilter = "Dubletten_Vorschlaege = ''"
notice the two single qoutes before the ending double quote.

Column references in formulas

I am a little stuck at the moment. I am working on an array of data and need to find a way to input column numbers into formulas.
-I have used the match function to find the corresponding column number for a value.
ex. "XYZ" matched with Column 3, which is equivalent to C1:Cxxxxxx
-now for inputing the C1:Cxxxxxx into a formula to get data for that particular column, I would like to be able to directly reference the Column 3 part, because I plan on using this workbook in the future and the column needed to run the calculation may or may not be column 3 the next time I use it.
- is there any way to tell excel to use a formula to tell excel which column to use for an equation?
so a little more detail, I have the equation
=AND(Sheet3!$C$1:$C$250000=$A$4,Sheet3!$B$1:$B$250000=$B$4)
instead of specifying to use column C, is there a way to use a formula to tell it to use C?
EDIT: more additional info;
"i am basically running the equivalent of a SQL where statement where foo and bar are true, I want excel to spit out a concatenated list of all baz values where foo and bar are true. ideally i would like it to ONLY return baz values that are true, then I will concat them together separately. the way I got it now, the expression will test every row separately to see if true; if there is 18K rows, there will be 18K separate tests.. it works, but it's not too clean. the goal is to have as much automated as possible. *i do not want to have to go in and change the column references every time I add a new data arra*y"
Thanks
You can use INDEX, e.g. if you have 26 possible columns from A to Z then this formula will give you your column C range (which you can use in another formula)
=INDEX(Sheet3!$A$1:$Z$250000,0,3)
The 0 indicates that you want the whole column, the 3 indicates which column. If you want the 3 can be generated by another formula like a MATCH function
Note: be careful with AND in
=AND(Sheet3!$C$1:$C$250000=$A$4,Sheet3!$B$1:$B$250000=$B$4)
AND only returns a single result not an array, if you want an array you might need to use * like this
=(Sheet3!$C$1:$C$250000=$A$4)*(Sheet3!$B$1:$B$250000=$B$4)
You could use ADDRESS to generate the text, you then need to use INDIRECT as you are passing a string rather than a range to the fomula
=AND(INDIRECT(ADDRESS(1,3,,,"Sheet3") & ":" & ADDRESS(250000,3))=$A$4
,INDIRECT(ADDRESS(1,2,,,"Sheet3") & ":" & ADDRESS(250000,2))=$B$4)
Obviously replace the 3s and 2s in the ADDRESS formulae with your MATCH function you used to get the column number. The above assumes the column for $B$1:$B$25000 is also found using `MATCH', otherwise it is just:
=AND(INDIRECT(ADDRESS(1,3,,,"Sheet3") & ":" & ADDRESS(250000,3))=$A$4
,Sheet3!$B$1:$B$25000=$B$4)
Note a couple of things:
You only need to use "Sheet3" on the first part of the INDRECT
Conditions 3 and 4 in the ADDRESS formula are left as default, this
means they return absolute ($C$1) reference and are A1 style as
opposed to R1C1
EDIT
Given the additional info maybe using an advanced filter would get you near to what you want. Good tutorial here. Set it up according to the tutorial to familiarise yourself with it and then you can use some basic code to set it up automatically when you drop in a new dataset:
Paste in the dataset and then use VBA to get the range the dataset uses then apply the filter with something like:
Range("A6:F480").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Sheets("Sheet1").Range("A1:B3"), Unique:=False
You can also copy the results into a new table, though this has to be in the same sheet as the original data. My suggestion would be paste you data into hidden columns to the left and put space for your criteria in rows 1:5 of the visible columns and then have a button that gets the used range for your data, applies the filter and copies the data below the criteria:
Range("A6:F480").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets _
Range("H1:M3"), CopyToRange:=Range("H6"), Unique:=False
Button would need to clear the destination cells first etc, make sure you have enough hidden columns etc but it's all possible. Hope this helps.