SSRS - Lookup field exported shown as #Error - excel

I was wondering if anybody else came across the same problem. It's been bugging me for weeks now.
I have a big table in my report pulling data from DataSet A, one column contains data from DataSet B and is pulled using the followin:
=Lookup(Fields!Date.Value, Fields!Date.Value, Fields!Sales.Value, "Sales")
Running report shows no errors, all numbers are displayed. However when I export the report to any format (tried CSV, EXCEL, PDF) the value from lookup column comes as #Error (CSV, PDF) or #VALUE! (EXCEL).
Looking for any help on the internet proved to be unsuccessful. Is there anybody who stumpled upon the same problem?

If you can lookup the data field from another dataset properly, it should not be the issue on lookup() function. I've also tested in my local environment, the data can be rendered after exporting. In this scenario, I suggest pay attention to the data type and data length. Can you show the sample data in your BIDS/SSDT?

Turns out it was the fact that I was returning more than one row from the other dataset (not always but in some cases yes). Normally I would create calculate field (different currencies and sales value) and sum them in the report. SSRS didn't have problem showing the first value by default but export functionality failed, since I did't SUM() rows that were find. I change the Dataset then to calculate the values after currency conversion and them wrapped it in another select statement to make sure I only have one for my Date.Value

Related

Excel Power Query truncating text field to 1024 characters

I am accessing a SSAS DMV through Power Query in Excel via:
let
Source = AnalysisServices.Database(TabularServerName, TabularDBName,
[Query="select * from $SYSTEM.TMSCHEMA_EXPRESSIONS"])
in
Source
This works great in Power BI, but in Excel, the Expression column is limited to a max of 1024 characters. How do I get Power Query in Excel to give me the entire value? My largest values are around 15000 characters, so still within the stated limits of Power Query that I can find.
If I set up a table with a connection and query behind it, Excel can pull in the entire Expression column, but the downside is the server and database cannot be parameterized and have to be manually changed in the connection. Also I don't remember how to do this manually, so I always have to access the DMV from DAX Studio and export to Excel to set it up!
Update
I did some heavy transformations of this column. I parsed out a value, I used it to merge the file with itself and add a column that I then did a bunch of transformations on, and then used it to replace text within the original problem column. And something in that pulled in the whole value. I tried just doing small parts of this, like adding a column that referenced the problem column, or doing a replace in the problem column, and none of that worked.
So, no, not easy to duplicate or figure out which step fixed it, but for my purposes, I now have what I need.
I think it is related to the type of the column your are loading in Excel. I had the same issue and read your answer (with Table.ReplaceValue).
Your solution is hiding the initial point : The function used in the expression you shared for Table.ReplaceValue() is Replacer.ReplaceText that as the additional specificity to convert a field of type Any
to type Text.
I tried to juste change the type of my field that was truncated when loaded in Excel, from type Any to type Text. Result : the complete values were then loaded in my worksheet.
I had to change this query today, and after I changed it, the values were truncated again. I added a Replace Value step at the end of the query on the truncated column and that seemed to fix it.
#"Replaced Value" = Table.ReplaceValue(#"Last Step","in ","in ",Replacer.ReplaceText,{"Truncated Column Name"})
in
#"Replaced Value"

Manually change Numeric parameters for OLAP formula

I had created a Pivot which uses Power Bi model as it's data source (Analysis services). Since my data is huge and there limitations of pivot, I am exploring other ways of pulling the data.
I converted the sample Pivot to Olap Formula and I think this is the best solution from all the options I have explored. But there is some odd situation I am facing where I need some help.
I tweaked the structure as shown below. So now whenever I change any string like in the below example if I manually change the currency from SGD to USD, I am getting the result. But whenever I try to Manually change any numeric value like Segment, I am getting #N/A. The same numbers when pulled using pivot gives the number.
I have tried to insert the numeric value in following ways
40
'40
="40"
=text("40",0)
text to columns->text
but till now I am not able to crack this.
The cubevalue function expects dimensions on which it is going to filter the values. If you want to provide the value manually you'll have to do it like this:
=CUBEVALUE("Sales","[Measures].[Profit]","[Time].[2004]","[All Product].[Beverages]")
Meaning you'll have to change the 40 to something like [MyDimension].[MyHierarchy].[40]

Transform data types in parts of a column

I am retrieving data through Power Query from an Oracle DB live to an Excel workbook. In PQ, under the "Transform" tab, there is a function to change the data type of a column, that I use to get all the decimal numbers displayed. In the M-code the function is called TransformColumnTypes. However I have some strings in the data that I cannot change to decimal number and produce an error. Is there a way to exclude these? Because the function takes the whole column at the moment.
Before applying function
Function producing error
Code
I don't think so. If you have multiple types within a column, text is the only one that doesn't produce errors.
But if it is only the first row like in your image, promoting it to header before setting the column type will fix the issue.

Excel: Inconsistent sorting criteria from 'Smallest to Largest' to 'A-Z'

Situation:
I am pulling information from a database and exporting it into an Excel 2010 template. The data consists of unique IDs (numeric), dates, and text in their respective columns. When going to sort, Excel usually recognizes the unique IDs as text and gives me the option of 'A-Z' which yields the correct result.
Problem:
Occasionally when sorting the unique IDs, Excel will give me the option to sort from 'Smallest to Largest' and when this happens the report yields a wildly incorrect result.
Pattern:
The sorting criteria is the only common denominator when a report fails, which makes little sense as they are both ascending orders. This issue only occurs ~20% of the time. The other times it sorts correctly from 'A-Z' as it does in the other worksheets within the same template.
-I've tried changing Number Format within the drop down to 'Text' 'General' and 'Numbers'
-I've tried manually sorting the data through filters as opposed to sort hierarchies
-I've tried clearing the table, and re-copying/pasting the data into the template's worksheet. This seems to work, but as the end goal is automation, I'd like to find out what the root cause is.
Expected result: Numeric data copied and pasted into the field to be sorted from 'A-Z', resulting in a successful report.
Actual result: Numeric data copied and pasted into the field typically results in the sort option of "A-Z', but occasionally sorts from 'Smallest to Largest' resulting in a failed report.
Excel is designed for numbers - and is generally very helpful in coercing text to numbers where appropriate. However, once in Number format the reverse is not easy. As you have discovered, merely choosing Text as format is not enough.
A clue is whether or not (assuming activated) the cells show green triangles.
Other than starting afresh with data entry into a cell already formatted as Text, the conventional solution for conversion with code is to prepend a quote, though appending a space would also serve.
Other than that, the easiest mass conversion approach may be to copy into Word (Keep text only) and copy back to Excel with pasting as Text.
The better solution may be to store IDs as text and prepend 0s to a standard length.

Which is the most flexible way for end-user to create a report querying an SSAS Cube?

I know that you can query a cube by connecting from Excel to Analysis database and using formulas like cubevalue() or cubemember().
I also know that after converting the power pivot to formulas, you can access the attribute and the value related only by writing a text.
Example: for Branch Dimension, instead of writing
cubemember("connections";"[DimBranch].[Name].[All].[London])" )
you can write in the cell only "London". However, this won't work if you have a parent-child dimension and want to retrieve the amount for one of the intermediate levels.
Did anyone know about how can you avoid writing these formulas directly by the end-user ?
I´ve done this several times. I can describe the approach I´ve used in the past.
You need to define the input from the user, for example Fiscal Year, Fiscal Period,... and create a tab with a friendly layout for this solely purpose.
After that you create your pivot/pivots against the cube/s you want to query with the data extraction that you need (obiously these pivots will refer to the Fiscal Year and Period). Define the desired layout for these pivots (as you want them you be shown). Once You´ve done this, you need to convert into formulas these pivots, including parameters. You´ll see that values placed in the measure box contain a formula cubevalue which makes reference to the connection itself and several cubemembers. It makes reference to the measure as well.
The trickiest part comes now, when you need to modify your cubemember function to take value from the input, something like cubemember("connections";"[DimBranch].[Name].[All].["+MyReferenceCell+")" ), and you have your dimension picked up from a value entered by a user.
If you have as a matter of fact, serveral pivots referencing common dimensions, you need to make the reference this modified cubemember cell affected by user input, otherwise you have to modify all affected cubemembers in your pivots converted to formulas.
This has a really good advantage: depending on the excel´s version, all pivots are automatically recalulated if you change the value in the user´s input cell without hitting the refresh all button.
On the other hand, the disadvantage comes when your report in excel contains a list of values from a dimension which can grow. After converting pivots into formulas those new values for the dimension are lost. That´s why you can always place a control if you have the total value int he pivots regardless the dimension value.
I hope this helps.
Regards

Resources