Power BI How to remove duplicate rows? - powerbi

In my report view, I have a table where the rows are repeated twice => once for each position available. I want to show only one row for each employee with his latest position. How can I accomplish this?
Name
Project
Date
Position
John Smith
PowerProject
01-01-2021
Engineer
John Smith
PowerProject
01-01-2021
Senior Engineer

Sort on the date. Group on the name. Choose All Rows as the function and change the code from _ to Table.Last(_) then expand

Related

Power BI DAX - sum all of one column but keyed off different table

This FEELS like something that can be done but I am at a loss for how to do it.
I have a table that has applicants for jobs...
name, requisition id, division, date applied, date hired
Each row is an applicant. Obviously not all applicants are hired. So in every row all fields are filled out with the exception of date hired for applicants that have not been hired.
I have slicers for month/quarter/year and division.
The date slicers all key off a field in every table called data_as_of which is the last day of the month with a one-to-many relationship with a date dimension table.
Here is a sample table...
[1]
[1]: https://i.stack.imgur.com/XQO9d.png
So here is what I'd like to do.
I'd like to slice by year and show a visual of all people hired in that year. Same with Quarter and Month (ie count all people in that quarter or month as appropriate). So far so good. That's easy.
Now on the same report page I'd like to show a visual (assume bar charts) that shows me a count of all the people that applied to the same requisition id prior to the date hired of whomever was hired in that requisition id.
Using the example above...
All of these examples assume 2021.
So if I used the month slicer in December I'd get 2 hirees in HR, Diane and Mel. In the second visual I'd get 7 Applicants.
If I used the month slicer to show November I'd get two hirees - Rhys and Jody. The applicant visual would show me 8 applicants. All 6 from requisition id 4 and 2 from requisition id 2 because one applied after Rhys was hired.
Consequently if I sliced for April of 2021 I'd get 1 hiree - Remi. In the applicant visual I'd get 4 applicants who all applied prior to Remi's hire date (including Morgan who applied in March but wasn't hired until May).
Does that all make sense?
I very much appreciate your help.
Best regards,
~Don

Power BI create 2 dropdown slicer on same table two columns

I need to have 2 dropdown slicers, on the same table. For example, consider the following table:
Country
State
India
PUNJAB
India
DELHI
USA
CALIFORNIA
USA
TEXAS
I want the first slicer to show a single selection of Country as a dropdown and the second Slicer to show State based on Country. For example, if India is selected then the second slicer should be showing PUNJAB and DELHI.
How do I achieve this, currently if I select any state say PUNJAB, the country is also getting filtered and changed to INDIA and I am not able to select USA.
You can go to Edit interactions under the Format pane and edit the second slicer to not cross-filter the first one.
Alternatively, you could use both in the same slicer as a hierarchy.

PowerBI/DAX - summing up group membership

I'm very new to powerBI and DAX. I have a challenge which is probably quite simple but I cannot figure it out.
To simplify, my data is basically a table of doctors, dates and points. Each doctor has a distinct and fixed region:
Doctor Region Points Date
John Doe A 3 2020-05-10
John Doe A 2 2020-05-10
John Doe A 4 2020-05-11
Mary Doe A 1 2020-05-10
Mary Doe A 3 2020-05-11
Jane Smith B 1 2020-05-10
Jane Smith B 1 2020-05-10
...etc...
It is simple for me to display this data as a line chart with date on the x-axis (using a date lookup table), and sum of points on the y-axis, where the doctor can be selected individually in an associated slicer.
Here is the challenge. I need to be able to chart both the sum for doctor and the sum of all points in the selected doctor's region (i.e. two lines on the chart, plotted by date) just by selecting the doctor on a single slicer.
I have experimented with creating a new column
report_points_all = CALCULATE( SUM(MyTable[points]), ALL(MyTable) )
But this is giving me nonsense data with enormous sums. I need to filter it down by the region associated with the selected doctor but don't have enough DAX skill to figure it out. Can anyone help point me in the right direction? Thanks in advance
Your current formula is not that far from working
report_points_all = CALCULATE( SUM(MyTable[points]), ALL(MyTable) )
But ALL(table) removes the filters on the whole table (doctors, date, region, etc), that's why you are probably getting one huge constant value.
What you want to do is removing the filter only on the the Doctor column
report_points_all = CALCULATE( SUM(MyTable[points]), ALL('MyTable'[Doctor]) )

Calculate Total male Total Female in powerbi report

I want to count the total number of males and females in a powerbi report
eg.
Name Gender
std1 Female
std2 Male
std3 Female
std4 Male
std5 Male
std6 Male
The result I want is:
Female 2
Male 4
To get the results you are looking for, follow these steps:
Make a second table using the New Table button with the following code:
GenderCounts = DISTINCT(TableName[Gender])
Make a relationship from the newly create table back to the original table
Add a new column to the GenderCounts table with the following code:
Count = COUNTROWS(RELATEDTABLE(TableName))
And there you have a second table containing the counts of each gender.
For more information and other possibilities, check out a related Power BI Community forum post here and Stackoverflow questions here and here.

Informatica Powercenter One to Many SQ Query and Mapping Issues

I have multiple VIEWs where the PERSON_VIEW to a PHONE_VIEW has a one to many relationship. In the following query, I got TOAD to correctly output the result into 1 row for each person record.
I am having a problem getting it to work with Informatica Powercenter. I copied/pasted the query to SQ SQL Query section.
Since the query takes the PHONE_NUMBER and check against the PHONE_TYPE on whether it is of type HOME, BUSINESS, or PERSONAL, it output 3 phone number columns called HOME, BUSINESS, and PERSONAL.
I created 3 new columns in the SQ Ports called HOME, BUSINESS, and PERSONAL to match the query output columns. When I validate the query, it constantly says it must match 28 ports from the SQ. When I just add 1 column and map to Exp Transformation and then to the Target, it still give this error. I counted the ports and it is 29. If I removed the phone columns, it works and the count is 28. When I add just one phone column, it gives the error.
I think I am missing a step.
Any help is appreciated.
PERSON VIEW
1 John M. Doe
PHONE VIEW
1 111-111-1111 HOME
1 222-222-2222 BUSINESS
1 333-333-3333 WORK
TOAD Result
1 John M. Doe 111-111-1111 222-222-2222 333-333-3333
Here is the QUERY (This works in TOAD)
SELECT PERSON.PERSON_ID,
PERSON.FIRST_NAME,
PERSON.MIDDLE_NAME,
PERSON.LAST_NAME,
PHONE.HOME,
PHONE.BUSINESS,
PHONE.PERSONAL,
PHONE_TYPE
FROM PERSON_VIEW PERSON
LEFT JOIN (SELECT * FROM (SELECT PERSON_ID, PHONE_TYPE,PHONE_NUMBER
FROM PHONE_VIEW)
PIVOT
(
MAX(PHONE_NUMBER)
FOR PHONE_TYPE in ('HOME' AS HOME,'PERSONAL' AS PERSONAL , 'BUSINESS' AS BUSINESS)
)
)PHONE ON PHONE.PERSON_ID = PERSON.PERSON_ID