I would like to set up initial value of lower category slicer whenever upper category slicer value changes. Suppose we have this data:
+----------------+----------------+-------+
| upper category | lower category | units |
+----------------+----------------+-------+
| fruit | apple | 1 |
| fruit | banana | 1 |
| vegetable | carrot | 1 |
| vegetable | potato | 1 |
+----------------+----------------+-------+
We add two slicer visuals to the report. It looks like this:
My desired results are this: Whenever the user selects fruit from upper category, then apple is selected from lower category slicer. So we end up with this:
Now the we click on vegetable in upper category slicer, and automatically carrot is selected as an initial filter value of lower category slicer. So we end up with this:
Summary:
Upper category slicer shows all items, regardless of lower category slicer choice.
Lower category slicer shows only applicable items, based on upper category slicer choice.
After selecting item from upper category slicer, always one initial aplicalble value of lower category slicer is selected.
After googling I have found this as a promising clue to the solution:
https://www.kasperonbi.com/embed-your-power-bi-report-with-predefined-filters/
I do not have to stick to slicer visual. It could be something else. What I want is to maintain this functionality. I could imagine that it could be accomplished with R visual by the concept expressed here: https://dataveld.com/2016/02/10/r-visuals-in-power-bi-beyond-plots/
Here is a start table code for your convenience:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSisqzSxR0lFKLCjISQXShkqxOgjRpMQ8IIQLl6Wmp5YkJoEVJicWFeWXYJUqyC9JLMmHSMUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"upper category" = _t, #"lower category" = _t, units = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"upper category", type text}, {"lower category", type text}, {"units", Int64.Type}})
in
#"Changed Type"
I don't believe this is currently possible with the default slicer as there is no way to programmatically set a slicer selection, but this related idea is a popular request that is currently "under review".
You can fake it by using the Bookmarks, but you need to effectively build a 'Parent' slicer using bookmark icons that sets the state of the other slicers
Here's how that looks:
That 'Parent' slicer at the top should be hidden.
Here's what happens if I click on the i icon under Fruit:
...and here's what happens if I click the other bookmark:
You can actually ditch the icons and have 'Fruit' and 'Vegetable' text instead. Here's how that looks:
Nothing selected:
Fruit clicked
Vegetables clicked
...although in reality you may need to space the fake Slicer Items further apart, as the title bar of the bottom one can cause issues with the interactivity of the top one, even though you can't see it. Here's a picture in Edit mode, so you know what I mean:
Furthermore, I find the 'Pin Visual' tip annoying, and there isn't (yet) a way to turn this off:
You could get fancier and have some kind of visual effect that somehow highlights which item in the fake slicer is selected. But the down side is that this approach doesn't allow you to handle dynamic lists of Slicer Items...you've got to set up each in advance.
Related
I have two tables, once for slicer and other one is for details table. The details table have a InvoiceDate column where some rows have blank InvoiceDate. The slicer table looks like below:
The slicer will only show value of of ID 1, like below.
Initially I want slicer to be un checked and the data should show only rows where InvoiceDate is Blank. Once User select the Slicer as Include Invoiced Records, it should show both full details i.e. Rows with Blank + Non-Empty dates rows.
There are two other ways of doing what you want that are probably more 'correct' but I'll also describe a way to provide the behavior you describe.
Option one: Delete your second table. Add a calculated column to your details table as follows:
Invoice Status = IF (ISBLANK([Invoice Date]) = TRUE(), "Not yet invoiced", "Invoiced")
Create a slicer using [Invoice Status] and simply default it to show 'not invoiced.' If users want to see the invoiced records, they just check that box in the slicer as well.
Option Two: Use Bookmarks and buttons to produce the desired effect. Create two buttons, one that says 'Include Invoiced Customers' and another that says 'Hide Invoiced Customers' -- create two bookmarks where one has the invoiced customers filtered out of the visual and one where the invoiced customers aren't filtered. Set each button's "Action" to the appropriate bookmark.
Option Three Keep your 'slicer' table. Let's assume it's called 'Invoice Filter Selection.' Create a new measure:
IncludeDetailFilter =
IF (ISFILTERED('Invoice Filter Selection'[Value]) = True(),
1,
IF (ISBLANK(MAX(InvoiceDetails[Invoice Date])) = TRUE(), 1, 0)
)
When the slicer has a selection, it will be considered 'Filtered' and you will pass into the first branch of the IF where the measure always evaluates to 1. When the slicer isn't selected, the measure will evaluate to 1 or 0 depending on whether or not there are any values for Invoice Date in the row. Add this new measure as a filter on your invoice detail visual.
Unchecked:
Checked:
Hope it Helps.
I am unpivoting few columns which are extracted from a Date field, to show as a radio button in the slicer.(fields are: "Daily", "Yearly", "monthly", "quarterly")
Qs.1: Can I show these values in a custom order like: "yearly", "quarterly", "monthly", "Daily"
Data format( I have used the "Attribute" column in the slicer to achieve the radio buttons)
Qs.2: To sort the x-axis I have used the main date field("app_submitted_date) on the tooltip.
If I don't use the "app_submitted_date" on tooltip will not be able to sort x-axis when "quarterly" & "monthly" is chosen.
While using the "app_submitted_date" filed on tooltip I am getting the tooltip in the following format:
How to customize the tooltip so that it will only show ( Female: count, Male: Count, Not Disclosed: count, Date: whatever date it is)
Please let me know for any clarification in the question.
Qs-1 Solution
Create a small table with two columns & 4 rows :
Attribute Names
Index
as follows :
| Year | 1 |
| Quater | 2 |
| Month | 3 |
| Daily | 4 |
Then, create a 1 to many relation between this table and the table that you showed in the question (Attribute to Attribute connect).
Then, instead of take the contents of this attribute column as a filter and prior to that sort this attribute column by index in the "Table View".
Qs-2 Solution
For this solution, I agree with the answer provided by Jon. There is no way to hide the thing that you have taken in tool tip; as of now.
Formatting the tool tip directly as you have suggested cannot be done, however there is a work around with 'Tool Tip' pages, that may help you show what you need.
You create a new page, with the measures in, this is then displayed as a tooltip over your data. Image taken from the MS Docs website
I have a table of Enter and Exit time of some people like this:
Name | EnterTime | ExitTime
=============================
Tom | 13:52:00 | 20:55:00
Robert | 15:55:00 | 21:12:00
Sarah | 19:08:00 | 19:48:00
Jack | 16:54:00 | 17:32:00
I want to show the user that in a selected point of time who has presence.
In other word, I want to have a dateTime slicer that the user will pick a time and then the table got filtered to show only rows with:
EnterTime < selectedTime < ExitTime
This can be done with a few steps.
First, we need a list of dates to go into our slicer. If you're using a separate date table, then that's a great source. Otherwise, you can build one with DAX that will contain all the dates in your EnterTime and ExitTime columns.
Click on 'Create Table' in the modeling ribbon. Put in the following DAX:
DateListTable = UNION(
SELECTCOLUMNS('MyTable', "DateList", 'MyTable'[EnterTime]),
SELECTCOLUMNS('MyTable',"DateList", 'MyTable'[ExitTime])
)
You now have a slicer and a table visual. Select the slicer and then navigate into the Format Ribbon (it's only available when the visual is selected. Use Edit Interactions to turn off the Slicer's filtering on the table. Set it to no interaction (the circle with a diagonal line through it).
Create a new measure
ShowDate =
VAR SelectedDate = SELECTEDVALUE('DateListTable'[DateList], BLANK())
Return
if(SelectedDate >= Max('MyTable'[EnterTime ]) && SelectedDate <= max('MyTable'[ExitTime]), 1, 0)
Finally, filter your table visual on the new measure, ShowDate, for when it is 1.
So, we create an independent slicer with a complete list of dates. But we break any filter relationship between it and the table. Instead, we use 'SelectedValue' to capture the value chosen from the filter, and create a dax measure that shows '1' when the value in the filter is between EnterTime and Exit time. Filter on that dax measure, and we get our desired behavior.
I have a data table, that contains survey data with the following column headers:
Answerid | Question 1 | Question 2 | Question 3
1 3 4 5
And a reference table that links question categories to the questions:
Question 1 | Category A
Question 2 | Category B
Question 3 | Category B
Now I would like to view results as averages on a Category level. For example in a bar chart where each bar shows the average value for that category.
Load in reference range with no column headers and call it Reference. Load in data table. Right click first column, choose Unpivot other columns. Home...Merge Queries... Merge to table Reference and click on Question column at top and bottom to link them. Expand results by clicking arrow box at top of new column. Right click column with Category, Group By, use average and apply to the column with numerical field. Add your own chart as desired
let Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"AnswerID"}, "Attribute", "Value"),
#"Merged Queries" = Table.NestedJoin(#"Unpivoted Other Columns",{"Attribute"},Reference,{"Column1"},"RefernceTable",JoinKind.LeftOuter),
#"Expanded RefernceTable" = Table.ExpandTableColumn(#"Merged Queries", "RefernceTable", {"Column2"}, {"Column2"}),
#"Grouped Rows" = Table.Group(#"Expanded RefernceTable", {"Column2"}, {{"Average", each List.Average([Value]), type number}})
in #"Grouped Rows"
How to capture slicer value by DAX measure in all circumstances? Let's have sample data:
+-----------+---------+-------+
| category | species | units |
+-----------+---------+-------+
| fruit | apple | 1 |
| fruit | banana | 1 |
| vegetable | carrot | 1 |
| vegetable | potato | 1 |
+-----------+---------+-------+
I added two measures:
Measure 1:
species selected = SELECTEDVALUE(Table1[species])
Measure 2:
IsFiltered = ISFILTERED(Table1[species])
Case 1. All items in both slicers selected.
Case 2. (problematic case). Fruits selected and Carrots selected (it is possible when we untie slicers interactions).
In case when we select fruit category from one slicer and carrot from another slicer there is a problem. This set of items is obviously empty. However definitely carrot from species have been selected and it is confirmed by IsFiltered measure which evaluates to True. Is there a way to capture that value in DAX measure?
Since both the category and species slicers come from columns on the same table, if you have both fruit and carrot selected, then the resulting table is empty and any measures (except ones that remove both filters) will therefore be working with blanks. You cannot have both filters apply simultaneously an expect them to act independently (even if the two slicer visuals don't cross-filter).
If you don't want your species selected measure to be influenced by category, the simplest thing to do would be to turn off filtering (under Format > Edit interactions) from the category slicer to the visual containing species selected.
This isn't always what you want though, so another possibility is to create a new table for the species slicer which has no filtering relationship from Table1. This will allow you to work with the slicers selections separately if that's something you need to do. (I've definitely had to do this before when I wanted a slicer to behave more like a parameter than a filter.)
Edit: To do what I suggested, create a new Table2 in the query editor that references Table1, remove all columns other than species and remove duplicate if necessary. You should now have a single column table that is a list of unique species.
When you close and apply, Power BI will likely automatically create a relationship between the two tables, but you need to make sure it's exactly what you want. It needs to be a many to one relationship with a single filter direction.
Once this is done, you'll need to replace the Table1[species] slicer with Table2[species] slicer as well as change references in measures where necessary.