Using Different, Aggregated Column as Column Name in Slicer - powerbi

I'm new to Power BI and trying to create a slicer for Classes by Instructor. The best value to display to the user is the name, since that is how users normally identify the instructors. The problem is that some instructors have had name changes. This actually leads to two problems:
1. How to roll the duplicates up into one item in the slicer selection options, and
2. How to use the combined underlying DimIDs for actually slicing the data.
Sample source table structure looks like this:
InstructorDimID InstructorID InstructorName
--------------- ------------ --------------
1 1 John Smith
2 2 Karen Jones
3 2 Karen Watson
4 3 Jennifer Anderson
5 3 Jennifer Hancock
Would like the slicer to look like this:
Jennifer Hancock
John Smith
Karen Watson
I have an idea of how I would do this in SQL but don't know if it's at all relevant for Power BI. I tried searching stackoverflow as well as Power BI sites with no luck; am looking for an approach that will help me learn how to "think in Power BI". Any tips are much appreciated.

This has to be a part of your data model.
Either add a new table keyed by InstructorID that has the current name of each Instructor, and a relationship with filter flow to your existing InstructorDim, or add a CurrentName column to your existing InstructorDim.

Related

Connecting Datasets in PowerBi by several variables

I have a dashboard that looks like this in PowerBi:
Almost every slicer and visual on this page comes from the "visits" dataset. That dataset is 70,000+ rows, where each row stands for a single patient visit to the hospital. There are a few relevant columns for this question such as: "subject mrn", and "protocol_no" (the study they're on).
Well, elsewhere, I have a dataset called "Data Managers" that is the staff assigned to each protocol. It has relevant columns of "subject mrn", "protocol no" and "staff name"
I have these datasets in my power bi like this:
When I connect these datasets by dragging in between them, Power BI warns me that they are many-to-many relationships. This makes sense because:
Lets say staff member John is the data manager for patient 12345 on study x
Well patient 12345 might also be on study y, and on that study, staff member steve is the data manager.
Also, other patients on study x might have other data managers.
So I need to connect these datasets in a way that when I filter to John, I only get rows back from the visits data where John is the data manager for that combination of subject AND study.
When I just drag across from protocol no and subject mrn like this
it doesnt work. The dropdown appears to filter to lists for john, but when I check for accuracy, its people with totally different data managers. Any idea what to do?
If anybody is looking at this, theres probably a way to do it with managing multiple relationships, but I ended up creating a concatenated column in each dataset of "Protocol, subject_mrn" and then linking those new columns together.

Comparing data for a month across a choice of 2 different years using slicers in Power BI

I am trying to create a tab in Power BI that includes a Year to Year Comparison for a month using a slicer on a date hierarchy, but I'd like the user to be able to chose which years are being compared (for future-proofing the report). This involves using 3 slicers on the report - 2 for the choice of 2 years, and 1 for the month of interest. I haven't yet found a way to get the data to show up for the graph I want.
I created a mock page that displays the type of report I'm looking for, but it only has a month slicer, and utilizes built-in page filters to constrain the years:
Reference image for what I'd like the graph to look like
What I'd like to create is a page with the filter options shown here, but it's not outputting any data, much less anything like the first graph (unless I have both year slicers to be the same):
Has the slicer options I want, but data doesn't show
I've looked into including some Time-Intelligent DAX functions, but from what I can tell, nothing seems to be an obvious solution for what I'm trying to do.
Start with two measures - one each for year 1 and 2 - to show the data for those years, and two unrelated slicer tables driving the year selection. Each measure can then pick up its year value (via SELECTEDVALUE) to use for data filtering.

Generate dynamic time representation using DAX

I am relatively new to PowerBI and struggling to accomplish the following task.
I have in total 3 Tables. 2 Tables are available and the 3rd is the outcome I am interested in.
Table 1 is a lookup table with yearly values for each option of a certain property.
Table 2 is a user input table containing the project list with a property that can be equal to one of the options in Table 1.
I am mostly interested in Mapping the projects with their yearly development based on one property. The outcome is represented in Table 3.
At the end of the day, I would like to plot the Sum across all projects against the year column (The 2 columns in red).
I hope someone can help here in finding the appropriate DAX logic. Thanks in advance!
You can bring the tables into a Power BI model, and from the modeling tab you can create relationships to accomplish this. Let me know if this is helpful.

Looking for DAX formula to calculate percentage per category for a year for a multiple choice ques

I have done almost everything but not able to achieve the desired solution.
I have two surveys for 2020 and 2021 which have multiple-choice questions.
So there are two tables:
Table 1
Table 2
Since it's a multiple-choice question, I want to calculate the percentage of respondents who chose e.g. western Europe as an attractive region based on total number of respondents for a survey. For this, I have linked the above two charts using Survey ID.
I want a measure to calculate the last column in below table 3:
Table 3
For eg. for Western Europe, 3 respondents in 2021 survey have marked it as a attractive region. Now the percentage I want is 3 divided by 4 (respondents in 2021 survey). The percentage I am getting is 3/9 (respondents in 2020+2021 survey)
This is the DAX I am using:
Denominator = calculate(sum('Table 2'[Weightage]),allexcept('Table 2',Table 2[Survey year]))
%category = divide(sum('Table 1'[Weightage]),Denominator,0)
Please suggest the change in DAX function to require desired percentage. Since its a multiple choice question I am facing issues. I really need this to be resolved, please suggest what can be done. Thankyou.

Power BI row reduction while summarizing a column

I'm sure the nature of my question will reveal I am a rookie at PowerBI. -- so, please, don't hesitate to write like you're writing to a 10 year old. I have a table with several records per person (sorted by person). Each record has a Weight. I want my PowerBi report to display only one record per person with the sum of all that person's weights. There might be a wrinkle in that the weight is in a different table (two tables away via two relationships). Since I am in learn mode, don't mind if solution comes in progressively more difficult steps (as the weight table gets further away from the people table).
Data model:
- 'PersonTable' related to 'TestTable' by 'Name'
- 'TestTable' related to 'WeightTable' by 'Test'
I have tried creating a new column (not measure) in the PersonTable (and I have tried putting a new column in the TestTable) and then using various formulas to try to sum the weights in the WeightsTable - to no avail. The summed weights always come back including the sum of all possible weights in the WeightsTable.
Here is some contrived test data and expected results....
* Name Test Weight
* ------ ----- ------
* Dave TestA 3
* Dave TestC 5
* Dave TestE 7
* Harold TestA 3
* Harold TestB 4
* Jack TestD 6
* Jack TestE 7
Desired Results:
* Dave 15
* Harold 7
* Jack 13
I have concocted a "codeless solution" using the groupby feature. I am dissatisfied with it though because I believe this approach will not allow me to "drilldown" through one of the aggregated records produced to see the detailed records that were grouped. That will be the subject of my next question.
Here is the "solution"...
Use the "Query Editor" to modify the 'TestTable'.
Merge the query for the 'WeightTable' into the query for the 'TestTable' keeping only the weight column from the merged in table.
Duplicate the new column. (I thought I would want two columns so that I could keep the un-grouped weights for detail reporting, but this has not been the case yet.
Push the "GroupBy" button on the ribbon for the "Home" tab and fill out form as follows...
Radio Button - Basic
Group by: "Name"
New Column Name: "Sum of Weights"
Operation: "Sum"
Column: "Weight-Copy"
This generated the values I am looking for but removed the columns holding the detail data in the 'TestTable' which I will need for later (possibly drillthrough) reporting. So I continue to seek a better solution...
I believe you've chosen a proper solution, up until step 4. Remove that step and load the joined dataset into the data model.
Then, just drag and drop the desired columns onto the canvas (weight and name). PowerBI will automatically sum the weights and then group that by name, producing your desired output.