Conditional Drill Down Powerview - powerpivot

Not sure if this is doable but I just wonder say if my data set got this structure
Department, Team, Service, Area
and I got a measure lets call it #count that count all rows in this table.
When create a powerview chart I want to be able to drill down by Department, Team, Service and Area.
However if say in Area there are following attributes
Area 1 - 10 rows
Area 2 - 5 rows
Area 3 - 3 rows
Is it possible to stop drill down if count row in certain area is less than 5 per se?
Appreciate all advice.
Many thanks
Peddie

Related

Cognos calculate using a different layout section

I have a Cognos report that has four different sections/layouts, each containing their own list. I would like to use one section to perform calculations using another list from another section. Is that possible?
For example:
Section Two contains a list with Name, Week1 Commissions, Week2 Commissions, etc
I want Section One to calculate the first 11 weeks only so the List in Section One would contain
Name, Weeks 1 through 11 total.
What is the best way to make this happen if it's possible.
Section One would contain these columns which would perform the calculations
Name Week 1-11 totals |
Section Two would have these columns
Name Week 1 Week 2 Week 3 .....
Best,
Kev
Yes it is possible, and you can perform all of the logic in one query
There are many ways to do this
For example, the four different sections/layouts, selecting the list, go to properties you can use the same query for each list

Using Count and Group By in Power BI

I have a table that contains data about different benefit plans and users enrolled in one or more of those plans. So basically the table contains two columns representing the benefit plan counts and total users enrolled in those plans.
I need to create visualization in Power BI to represent the number of total users enrolled in 1 plan, 2 plans, 3 plans, ...etc.
I wrote the query in sql to get the desired result but not sure how do I do the same in power BI.
Below is my sql query:
SELECT S.PlanCount, COUNT(S.UserName) AS Participants
FROM (
SELECT A.Username, COUNT(*) AS PlanCount
FROM [dbo].[vw_BenefitsCount_Plan_Participants] AS A
GROUP BY A.username
)AS S
GROUP BY S.PlanCount
ORDER BY S.PlanCount
The query result is below image:
So here, PlanCount column represents the total different benefit plans that users are enrolled in. For e.g. the first row means that total of 6008 members are enrolled in only 1 plan, whereas row 2 displays that there are total of 3030 members who are enrolled in total of 2 plans and similarly row 5 means there are only 10 users who are enrolled in total of 6 plans.
I am new to Power BI and trying to understand DAX functions but couldn't find a reasonable example that could help me create my visualization.
I found a something similar here and here but they seem to be more towards single count and group by usage.
Here is a simple example. I have a table of home owners who have homes in multiple cities.
Now in this table, Alex, Dave and Julie have home in 1 city (basically we can say that these 3 people own just 1 home each). Similarly Jim owns a total of 2 homes and Bob and Pam each have 3 homes in total.
Now the output that I need is a table with total number of home owners that own 1 home, 2 homes and so on. So the resulting table in SQL is this.
Where NameCount is basically count of total home owners and Homes is the count of total homes these home owners have.
Please let me know if this helps.
Thanks.
If I understood fine, you have a table like this:
BenefitPlan | User
1 | Max
1 | Joe
2 | Max
3 | Anna
If it's ok, you can simply use a plot bar (for example) where the Axis is BenefitPlan and Value is User. When you drag some column in Value field, it will be grouped automaticaly (like group by in SQL), and by default the groupping method is count.
Hope it helps.
Regards.
You can use DAX to create a summary table from your data table:
https://community.powerbi.com/t5/Desktop/Creating-a-summary-table-out-of-existing-table-assistance/td-p/431485
Once you have counted plans by customer you will then have a field that will enable you to visualize the # of customers with each count.
Mock-up of the code:
PlanSummary = SUMMARIZE('vw_BenefitsCount_Plan_Participants',[Username],COUNT([PLAN_ID])

With MDX is there a generic way to calculate the ratio of cells with regards to the selected members of a specific hierarchy?

I want to define a cube measure in a SSAS Analysis Services Cube (multidimensional model) that calculates ratios for the selection a user makes for a predefined hierarchy. The following example illustrates the desired behavior:
|-City----|---|
| Hamburg | 2 |
| Berlin | 1 |
| Munich | 3 |
This is my base table. What I want to achieve is a cube measure that calculates ratios based on a users' selection. E.g. when the user queries Hamburg (2) and Berlin (1) the measure should return the values 67% (for Hamburg) and 33% (for Berlin). However if Munich (3) is added to the same query, the return values would be 33% (Hamburg), 17% (Berlin) and 50% (Munich). The sum of the values should always equal to 100% no matter how many hierarchy members have been included into the MDX query.
So far I came up with different measures, but they all seem to suffer from the same problem that is it seems impossible to access the context of the whole MDX query from within a cell.
My first approach to this was the following measure:
[Measures].[Ratio] AS SUM([City].MEMBERS,[Measures].[Amount])/[Measures].[Amount]
This however sums up the amount of all cities regardless of the users selection and though always returns the ratio of a city with regards to the whole city hierarchy.
I also tried to restrict the members to the query context by adding the EXISTING keyword.
[Measures].[Ratio] AS SUM(EXISTING [City].MEMBERS,[Measures].[Amount])/[Measures].[Amount]
But this seems to restrict the context to the cell which means that I get 100% as a result for each cell (because EXISTING [City].MEMBERS is now restricted to a cell it only returns the city of the current cell).
I also googled to find out whether it is possible to add a column or row with totals but that also seems not possible within MDX.
The closest I got was with the following measure:
[Measures].[Ratio] AS SUM(Axis(1),[Measures].[Amount])/[Measures].[Amount]
Along with this MDX query
SELECT {[Measures].[Ratio]} ON 0, {[City].[Hamburg],[City].[Berlin]} ON 1 FROM [Cube]
it would yield the correct result. However, this requires the user to put the correct hierarchy for this specific measure onto a specific axis - very error prone, very unintuitive, I don't want to go this way.
Are there any other ideas or approaches that could help me to define this measure?
I would first define a set with the selected cities
[GeoSet] AS {[City].[Hamburg],[City].[Berlin]}
Then the Ratio
[Measures].[Ratio] AS [Measures].[Amount]/SUM([GeoSet],[Measures],[Amount])
To get the ratio of that city to the set of cities. Lastly
SELECT [Measures].[Ratio] ON COLUMNS,
[GeoSet] ON ROWS
FROM [Cube]
Whenever you select a list of cities, change the [GeoSet] to the list of cities, or other levels in the hierarchy, as long as you don't select 2 overlapping values ([City].[Hamburg] and [Region].[DE6], for example).

SSRS Lookup on single dataset

Hopefully you can help!
I have a single data source in my SSRS report. With this data source, I have populated a tablix. The tablix looks something like this:
SalesPerson ID Group Sales
Sarah 1 1 1234
Ross 2 1 555
Gemma 3 2 678
Jill 4 2 345
Jack 5 3 987
Peter 6 2 432
Henry 7 2 356
The report is set up to create a different page for each of the sales people. for example, on the first page of the report, only first record would be shown (the record that holds Sarah's information, the second page would show the record for Ross' information ,etc..)
The issues I face is this:
At the bottom of the report, I need to include a textbox that displays the group number that the specific employee belongs to (the employee who is currently being displayed on the page).
I think that I need to do some sort of lookup on the IDReportItem to return the group ID in order to do this, but have had no luck in my attempts.
I understand that this is a horrible way of doing things, but I am limited to using this single dataset for performing this task.
Any help you can provide will be greatly appreciated,
Thanks you!
Unfortunately there doesn't seem to be a way to do this in a single textbox, but you can do it with a second tablix that uses the same dataset.
Create your second tablix and position it at the bottom of the page, then set your grouping to be the same on both tablixes and use the second tablix to only display the group ID, plus whatever label you want.
Create a new row group for each tablix (grouping on group ID), then right click the group and browse to Group Properties -> Page Breaks and check the box that says "Between each instance of a group". Do this for both tablixes.
This is what grouping is designed for. Build your table, and set the page break attribute to true.
You can have multiple rows under your group. Since your group is a field, simply add it to the detail row.
Your grouping is obviously set up right to get the report paging correctly.
You could add a List to the report, set the grouping on that (with page break between groups)
Inside the list - Add a RECTANGLE. (this be important!)
Once you've added the rectangle, you can add another as many objects as you like. In your case I think that may be a matrix and a text box
eg
Then it just becomes as spacing issue (to get the page looking right)

Complex SQL Query with Business Logic

I'm stuck with a complex query where I need to implement some business logic. Below are the tables that I'm having (I have omitted extra columns for readabality)
Team - TeamID, TeamName
TeamMember - MemberID, TeamID, MemberName
Question - QuestionID, CategoryID, DifficultyLevelID, Question
Category - CategoryID, CategoryName
DifficultyLevel - DifficultyLevelID, DifficultyLevelName
QuestionOffered - QuestionOfferedID, QuestionID, OfferedTo
Now, The business logic is, I have 10 categories (like Science, History, Geography etc.) and 3 Difficulty level (i.e. Easy, Medium, Hard). Each category and difficulty level have 5 questions.
So 3 x 5 = 15 questions for each category (5 Easy, 5 Medium, 5 Hard). Total 15 x 10 (categories) = 150 questions.
Now I want that everytime a user comes in, I'll check whether I have already offered (can be tracked from QuestionsOffered table) all the 5 questions under that category and difficulty level, if so, then I won't show that category and difficulty level again.
So, say I come in first time I'll get all the category and then selecting a category I'll get all the difficulty level. Now I select Easy and proceed. So under each category I can select a particular difficulty level 5 times after that I'll get the category and other difficulty levels (i.e. Medium and Hard) after I have done with all 5 easy.
So, in this way, if I'm done with all 5 easy, 5 medium and 5 hard questions under a same category, the category itself won't show up.
Ofcourse I can implement this logic in programming for populating the category but that would end up with numerous lines of code.
So is there any way to check this business logic in SQL? So that I will get the data to populate?
inner join your questions, categories, and levels together, then left join to the questions already offered. Filter where any field in the questions offered table is null, and you will have a list of unanswered questions? perhaps?