Power BI create 2 dropdown slicer on same table two columns - powerbi

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.

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

How to display the selected country name from slicer when there is no data for the selected month and the selected country in power BI with the DAX

I have a table with the Country and Date columns.
I have a slicer with Country and Date, now as I select the slicers for UK and May-21, it shows blank as the data is not there for May-21.
Now I always want to display the selected country whether there is data or not. I tried creating a measure using DAX, REMOVEFILTERS, and many other things but it's not working.
Any help would be appreciated. Thanks.
use this code :
SELECTED COUNTRY =
var __coutries = CALCULATETABLE(values('your table name'[Country]), ALLEXCEPT('your table name','your table name'[Country]))
RETURN
IF(COUNTROWS(__coutries) == 1, __coutries, "")
this article reveals how to manage the familly of allxxx functions.

How to set a default selection for a slicer in power bi and estabilsh connection betwwen two slicers?

I have slicer which is showing options to select a year, this field is not directly used in any of the graphs. How to set the current year to be selected in this dropdown.
And in another slicer, I have given the option for the date range, I want by default it should show the current date range as per the "year to view" slicer.
How to achieve this?
Please see the attachments for clarity.
You can apply a descending order to your YEAR slicer and make "Single Select" on from the slicer properties. This way the top most value will automatically selected when you refresh your report and for a descending order, current Year value will be on top and selected.
The date range slicer will also populated based on the selected value in the Year slicer.

How do I filter the columns of a table visualization?

Using the following sales table as an example which records the volume of products sold by each salesperson per year:
I created a stacked column visualization showing products sold per year:
What I want to happen when I click on "Cakes" is a report to show:
Resource, Year, Cakes
Rajeev Argwal, 2018, 678
Rajeev Argwal, 2019, 876
Rajeev Argwal, 2020, 2
When I select a specific item in the stacked column such as "2019 Soup" I want the report to show:
Resource, Year, Soup
Jane Smith, 2019, 800
Rajeev Argwal, 2019, 225
What is the right approach to do this? Effectively filtering the table visualization to show only the relevant rows and columns.

How to filter a Pie chart by selection in table

Please consider this scenario:
I have a table in Power-BI that's like this:
Country Total Sales
-----------------------------
USA 2000
Canada 1400
Spain 3200
And I want to have a Pie chart in page that if user clicks on every rows, The pie shows sales type for that Country. For Example:
How can I connect these to visuals together?
Thanks
If the two visuals shows data from the same data source, then they will be "connected" by default, i.e. when the user clicks on a row in the table, the pie chart will show only the data from the selected country, and if the user clicks on a sector from the chart, the table will show only the amounts for this category.
If you have a table in your data source like this:
Then add a table in the report with columns Country and Sales like this:
By default amounts will be aggregated as sum, so the table will show sum of Sales per Country. You can change the default summarization of the currently selected field in Modeling tab:
Add a pie chart with Category field in the legend and Sales field for value. Change the value to be shown as percentage from the grand total like this:
Adding Sales field as tooltip will also show the amount when pointing to a sector:
Now when you click on a row in the table, the pie chart will show only the relevant data:
For more information take a look at Change how visuals interact in a Power BI report and Filters and highlighting in Power BI reports articles.
Well, it does not work if the pie chart is top-N pie chart. I open a new issue to the Power BI community to fix it. Here is a description of the issue: Basically, I have a top-N pie chart created for states. But, when I select a city in a table and the city is not in one of those states, the pie chart is not updated to show the state of the selected city. Instead, it remains to show those top-N states with 0% in every slices. This is wrong. It should show the top-N states of the "selected" cities.