Hide a row in Excel OLAP pivot table - sql-server

I have an Excel sheet which connects to a cube. The information is presented in a pivot table. The problem is that I need to hide one member of the dimension on the rows axis.
That is I have the following table.
a value1
b value2
c value3
total
I want to hide the row with value b. I cannot solve this with filters in the pivot table since the member must always be hidden and if the filter is used then a user can select it.
What I have tried so far:
Use a named set with an MDX calculation. This does not work since a named set cannot be used in filters.
Use a calculated measure IIF(currentmember = b, null, value). This does not work since the grand total still includes the value for b.
Any suggestions? I prefer not to create a scoped member in the cube specifically for this report.

In case anyone is still interested I found a solution to the problem.
Created a new measure in the cube with a null value.
Created a scope calculation for the measure in the cube, IIF(currentmember = b, null, value).
Created a new perspective in the cube list where the new measure is not visible.
Lots of work but I could not find any other options in this case.

I've searched high and low for this answer.
I had a similar issue. I was trying to calculate a measure from other 3 measures then filter and aggregate the filtered result. I came up with this:
Calculate the column in the source view table ( a - b + c = x)
Add the unfiltered calculated column (x) to the dsv
Create a named calculation in the dsv that uses a case statement to filter the original calc measure
Add the named calculation as measure
I choose to do it this way to capture the measure unfiltered first then, if another filter needs to be added or one needs to be taken off I can do so without messing with the views again. I just add the new dim to filter by to my named calculation case statement.

Related

Google Data Studio : how to obtain a SUM related to a COUNT_DISTINCT?

I have a dataset including 3 columns :
ID transac (The unique ID of the transaction - Dimension)
Source (The source of the transaction - Dimension)
Amount € (The amount of the transaction - Stat)
screenshot of my dataset
To Count the number of transactions (for one or more sources), i use COUNT_DISTINCT function
I want to make the sum of the transactions amounts (for one or more sources). But i don't want to additionate the amounts of the transactions with the same ID !
Is there a way to do this calcul with a DataStudio function ?
Thanks for your answers. :-)
EDIT : I saw that we could do this type of calculation via SQL here and I would like to do this in DataStudio (so that I don't have to pre-calculate the amounts per source.)
IMO, your dataset contains wrong data. Each value should be relative only to that line, but this is not the case: if the total is =20, each line should describe the participation of that line to the total. With 4 sources, each line should be =5 or something else that sums 20.
To solve it in DataStudio, you need something like CALCULATE function in PowerBI, but currently DataStudio doesn't support this feature.
But there are some options to consider to repair your data:
If you're sure there are always 4 sources, just create a new calculated field with the expression Amount/4 and SUM it. It is not an elegant solution, but it works.
If your data source is Google Sheets, you can easily repair the data using formulas, like in this example:
Link to spreadsheet
For this spreadsheet, I used this formula in adjusted_amount column: =C2/COUNTIF(A:A,A2). With this column in DataStudio, just use the usual SUM aggregation function to summarize it correctly.

Creating a Measure to calculate Percentage in Tableau

Normally in Tableau to calculate % I create a measure and use the below logic;
SUM ([MEASURE_1])/ SUM([MEASURE_2])
However i am trying to get the % when using a measure and an already aggregated measure and I'm getting the below error;
Argument to SUM (an aggregate function is already an aggregation, and cannot be further aggregated.
My percentage is to calculated the % difference between a policy count from table 1 which is a measure. and measure 2 which I had to create to get the count of policies from table 2 as follows; Count([Policy]). I'm using SQL Server database.
Any ideas how i can resolve this issue?
Thanks!
Measure 1 is a count from table 1, the data looks like the following;
Measure 2 is from table 2, I am creating a count in tableau of the policy number, the data looks like the below;
The 2 tables join on agent number
Table 1 structure;
[UNIQUEPOL_CNT]
,[UNIQUEAGT_CNT]
,[VECHICLE_TXT]
,[VEHICLE_DESC]
,[VEHICLE_CD]
,[CODE_DESC]
,[POLICY_ID]
,[POLICY_NBR]
,[STATE_CD]
,[AGENT_NBR]
,[AGENT_NM]
,[PROP_ID]
,[WRITTEN_DT]
,[PURCHASE_DT]
,[SUSP_IND]
,[SUSPEND_DT]
,[BIND_ID]
,[INSURED_NM]
,[CHANGEDBY_ID]
table 2 structure;
[REPORT_DT]
,[AGENT_NBR]
,[TRR_TOTALPIF_CNT]
,[TRR_TOTALPON_CNT]
,[TRR_TOTALREV_CNT]
,[TRR_TOTALERR_CNT]
This is the invalid output...
UPDATED
I created two datasets to demonstrate you a solution
dataset1
dataset 2
Connecting both datasets in Tableau.
I built a view in tableau as (Note policies field blue color as it has been converted to dimension)
Now calculate a field as
ATTR({FIXED [Agent code]: count([Policy no])}/[Policies])
Adding this to viz gives me
wherein desired percentages are displayed.
Note- since the tables have one-to-many relationships fixed statement in respect of measure on lesser side of relationship will also result in same result.
ATTR({FIXED [Agent code]: count([Policy no])}/
{FIXED [Agent code]: AVG([Policies])})

Power BI - Show all data from table1 in a visual from two many to many related tables when one other field from table2 on the X-axis

I have a key column in two many to many related table and sample representation of data is -
(attaching sample version of the table to get the point across as there are other numerous columns not contributing to this visual)
table 1 -
table 2 -
I am making a line graph with date on x axis and the value1 and value 2 on y-axis. The value1 is true for all dates. It is basically a standard target value. Now I want all the value1 summed up to show in my visual as value1 and not just the ones for which I have data on those dates. To explain it better I want 1717 on the graph as well like the total in the table in the following image -
visual -
Is there a way to do this in power BI? I tried to make a shared dimension of all unique key as a separate table and connecting both the tables to that table but there is no change in visual due to that.
You can follow these below steps to achieve your required output-
Step-1 Create a custom column in your *table 1 as below-
value_1_sum =
CALCULATE(
SUM(table_2[value1]),
ALL(table_2)
)
Step-2 Configure your line chart as below. Remember, the aggregation for new custom column will be Average as shown in the image
And here below is the final output-
Additional Reference Here below is list of options you will get after right click on the measure name-

How to count unique occurrences with criteria in excel

I'm using the below array formula to count the unique occurrences of text in column C using the agent name in column G as the reference. This is giving me multiple issues.
=SUM( --(FREQUENCY(IF(G3:G100000 = J5,MATCH(C3:C100000,C3:C100000,0)),ROW(C3:C100000) - ROW(C3) + 1) > 0))
Depending on the data set I'm using multiple agents will return a #N/A result and I can't figure out why.
Each dataset I'm using is 20k to 30k lines, so the formulas take a long time to process.
Any ideas how I could do this faster or better? Also any ideas why some agents get bad returns?
I am assuming that you are looking for the number of unique combinations of columns C and G.
Create a pivot table and check the box to add this data to the data model.
Drag both column headers to the Rows section, also drag one (of those same two) into the the values section.
click on the the field in the values section > value field settings > summarize values by > choose Distinct Count. This removes all duplicates.
Click the Row Labels filter and uncheck the blanks.
You can drop in new data then right-click on the pivot and refresh to see the new results. See the image.

MDX - How to know if a measure has been pivoted with a dimension?

I was hoping someone could help me with this problem.
In a sum type measure, i need to know if this measure has been pivoted with my time dimension. If is not, the measure must show the sum of the last day. In other case, the measure must show the sum of the day with has been pivoted.
I have the measure "Users", if this measure hasn't been pivoted with my time dimensión, it shows the sum of all users of all the time. For example it shows: 5,000,000. When it has pivoted with the time dimension, it shows de users from the day. For example: 100,000 for today 21/05/2015.
When this measure hasn't been pivoted with the "time" dimension, the measure must show 100,000 and not the total sum of all days.
I've been trying white some MDX formulas but i have not found some solution for this.
Thanks
I've interpreted this as when pulling your Users measure without pivoting on the Time dimension you would prefer to see the value that corresponds to the current date.
This can be achieved by modifying the Default Member of your Time dimension. Setting the default date to this last available date
Within your Dimension in SSAS, browse to the Dimension Structure tab and select the attribute which represents the key column (ie. the Usage property is set to Key for only one column)
Within the Properties pane (strike F4 if you do not see it already to open it) select the Default Member property, then select the elipses (...)
The Set Default Member - [Dimension Name] pane will have 3 options, select the last Enter an MDC expression that specifies the default member
Use ONE of the following expressions
TAIL([Date].[DateAttribute].Members).Item(0)
TAIL(NONEMPTY([Date].[DateAttribute].Members)).Item(0)
TAIL(EXCEPT([Date].[Date].Members,{[Date].[Date].[Unknown]}),1).Item(0)
In my case I used the last as I only want to exclude my UnknownMember member
Now when you pull the measure down the value will be for the last date in your cube. This will affect other cubes built on this date dimension of course.

Resources