" slicer"
26 TopicsRead slicer values, retrieve corresponding table column values and use them to check existence
Hi all, I am trying to retrieve a column values based on the selected single/multiple slicer values and use those data to check their existence in the other table. Let me put this out clearly. There are two tables i.e., Calendar and Employee data. The calendar has the following columns i.e., fiscal year, fiscal year period, date. Adding the screenshot below. Calendar table: The Employee table has Name, Location, Joined Date. Employee table: The slicer in the Power BI dashboard is added with the 'Fiscal year period' column from 'Calendar' table. If the user selects a particular fiscal period or multiple fiscal periods, the corresponding dates from the Calendar table have to be read in a dax calculation and check the existence of those date values in the Joined date column in the table 'Employee'. For instance, if the user selects 2025 P3 and 2025 P4 from the slicer, then the corresponding dates from 3rd March to 4th May have to be read and check if any of those values exist in the column from other table i.e., in Joined date from Employee table. Could you please help me with a dax calculation/measures for this scenario? Any suggestions will be appreciated. Thanks! Microsoft EnterpriseDNASolved1.2KViews0likes6CommentsSorting Data in Different Order Based on Slicer Selection in Power bi
Hi Everyone, I want to sort the data in a specific order. When I select a value in the slicer. Below is the raw data: Table : Year Month Product Amount 2023 1 AA 100 2023 2 BB 200 2023 3 CC 100 2023 4 DD 100 2023 5 EE 300 2024 1 AA 300 2024 2 CC 500 2024 4 DD 600 2024 5 ZZ 300 2024 6 BB 300 slicer : order Required The order in which the products need to be sorted, when we select the year from slicer.Solved2KViews0likes5Comments"Sorting Matrix Data Based on Slicer Selection
Hi Everyone, I want to sort the data in a matrix in a specific order. When I select a value in the slicer, Below is the raw data image : The matrix contains Product and Value [Measure]. Raw Data Slicer : The order in which the products need to be sorted on the year value selected in the slicer. Raw Data: Table Product Year Value P3 2023 100 P2 2023 200 P1 2023 300 P8 2023 40 P6 2023 100 P1 2024 200 P3 2024 300 P2 2024 40 P14 2024 100 P12 2024 200 slicer slicer Year 2023 2024 Order needed Order Required [ when I select year in Slicer ] 2023 2024 Order order P1 P1 P2 P2 P3 P3 P6 P12 P8 P14 BeaBFSolved536Views0likes1CommentCalculating Active Employees from Most Recent Record
Hello, I am trying to analyze workforce metrics over time. I have a fact table that has a record for each time an employee file has changed. It has at least one record for every employee. This table includes unique employee ID, Start date, division, Term Date, Effective Date (when the record was created) and a calculated column of Record Order- which numbers the rows for each employee, with 1 being the first record, 2 being the second and so on. I also have dimension tables for Date, Org Structure (Division/Section) Demographics I need to count active employees at a point in time where Start date <= SelectedDate, TermDate is blank, or > SelectedDate. The issue I am running into is; if an employee has been active in two divisions at different times during the selected period, they are Distinct Counted in each division. This means that the overall organization numbers are accurate, BUT they will count as an employee in each division when that slicer is applied. I need to be able to use just the most recent record for each unique employee- as that most recent record will show their current location. Example Data: PS ID start date Division Term Date RecordOrder Eff Date 1 1/1/2020 A null 1 5/18/2020 1 1/1/2020 A null 2 5/19/2020 1 1/1/2020 B null 3 7/11/2020 1 1/1/2020 B null 4 10/3/2020 2 1/2/2020 A 4/2/2021 1 1/2/2020 2 1/2/2020 A 4/2/2021 2 10/3/2020 3 1/1/2020 A null 1 1/1/2020 3 1/1/2020 B null 2 10/3/2020 In the above data set, using a date slicer on say 10/4/2020, I would want to return a distinct count (3) active employees, 2 in division B. 1 1/1/2020 B null 4 10/3/2020 2 1/2/2020 A 4/2/2021 2 10/3/2020 3 1/1/2020 B null 2 10/3/2020 The first approach I took was to use an 'events in progress' methodology 1. Measure to count all employees based on Start Date 2. Measure to distinct count all active employees at point in time where start date<= selected date, and term date is blank or after Selected date this returns accurate counts for the whole organization- but when appling division slicers, it counts employees as a member of every division they had been active in at any point. So, if someone was in A and later B- they would show up when slicing by A or B. I need to return only the most recent record. The next approach I tried was to identify the MaxRecordOrder of each ID, and filter the active employees measure where RecordOrder=MaxRecord Order: MaxRecordOrder = CALCULATE( MAX(Employee_Fact[RecordOrder]), ALLEXCEPT(Employee_Fact, Employee_Fact[PS ID], 'DateTable') ) Active Employees= VAR EndDatePerVisual = MAX('DateTable'[Date]) VAR RESULT = CALCULATE( DISTINCTCOUNT(Employee_Fact[PS ID]), REMOVEFILTERS('DateTable'), FILTER( Employee_Fact, Employee_Fact[Start Date] <= EndDatePerVisual && ( Employee_Fact[Term Date] > EndDatePerVisual || ISBLANK(Employee_Fact[Term Date]) ) && Employee_Fact[RecordOrder] = [MaxRecordOrder] ) ) RETURN RESULT This approach seems to correctly identify the max RecordOrder for each ID, responsive to the date slicer- but still counts rows where the MaxRecord order <> RecordOrder- so employees are still showing up in counts for multiple divisions! I've also attempted the second approach using the max effective date in place of the RecordOrder calculated column, with no success. Any help would be appreciated!651Views0likes1CommentFilter based on multiple slicer values
I have a two table with below schema Table 1 ID | Name | Value| In Table 1 each ID can have multiple Name and value pairs. So I have combined all Name & Values pairs in Table 2. Table 2 ID | Combined Values Combined values will look like "name1:values,name2:value2". Now I need to support multiple filters on names and values, first drop down for name1 second drop down for value 1 Third drop down for name2 Fourth drop down for value2, Now I need to filter my tables based on these four entries. I need to filter ID's where "name1:values,name2:value2" is present. Can you please suggest on how we can achieve this?Solved978Views0likes4CommentsDAX and external filters
Hello, I have a small dataset (for training) using the following data model : I would like to calculate the percentage of sales (quantity) for any country / city related to global sales for Germany. So I used the following expression : measure15 = var currentSales = sum(sales[quantity]) var salesGermany = CALCULATE(SUM(sales[quantity]),ALLSELECTED(clients[city]),clients[country] = "Germany") return divide(currentSales,salesGermany) The measure works properly as long as the field clients[city] isn't filtered : case1 : case2 : case 3: I find th 3rd result a bit puzzling, could you kindly provide an explanation (why the part salesGermany is blank) ? Thanks in advance,Solved1.9KViews0likes4CommentsWriting measure to show multiple visuals on the same chart with one slicer
Hello, I am sorry to keep posting looking for a solution on this. I am trying to write a measure. I have tried multiple methods but cant get anything to work. I would assume having two different measures on the same visual would work. I have two tables (Table1 and Table2). My goal is to use one slicer and show multiple visuals from the same table on the same chart. For example, if a month is selected, I want to show data (filtered with different conditions) for that month, and the month most recent to the selected month. Column 'Table1'[Month] is linked to Column 'Table2'[Month] with a one to many relationship (Table2-one, Table1-many). Then I have a slicer that uses column 'Table2'[Month]. The visual for my current month works, but now I am trying the add the data to the same visual for its previous month. For the previous month, If the user selects a month with the slicer, I want to save the [Previous Month] associated in Table2 column as text. So if 24-Jun is selected, I want to save "24-May" as text. Then I want to filter and count the number of rows in Table1 where [Month End] = the saved text & Type = "Task". So in this example, I would count the number of rows in Table1 where Table1[Month End] = "24-May" & Type = "Task", and this would return 1. Table1 ID Status Date Rank Previous Status Month Type Group Previous Month A Normal 3 No previous 24-Mar Task <0 No previous B Normal 3 No previous 24-Mar Task 1 to 5 No previous C Not Normal 3 No previous 24-Mar Task 1 to 5 No previous D Not Normal 3 No Previous 24-Mar Not Task 11 to 15 No previous A Not Normal 2 Normal 24-May Task 6 to 10 24-Mar B Normal 2 Normal 24-May Not Task 6 to 10 24-Mar C Normal 2 Not Normal 24-May Not Task 6 to 10 24-Mar D Not Normal 2 Not Normal 24-May Task 6 to 10 24-Mar A Not Normal 1 Not Normal 24-Jun Task 1 to 5 24-May B Not Normal 1 Normal 24-Jun Task <0 24-May D Normal 1 Normal 24-Jun Task <0 24-May E Normal 1 24-Jun Task 1 to 5 24-May Table2 Date Rank Month Next Date Rank Previous Month 3 24-Mar 4 2 24-May 3 24-Mar 1 24-Jun 2 24-May Sample of visual I'm trying to create: Measure that doesn't work for previous month: (I keep getting blank when selecting a current month) VAR SelectedMonth = SELECTEDVALUE('Table2'[Month]) VAR PreviousMonth1 = CALCULATE( MAX('Table2'[Previous Month]), FILTER( ALL('Table2'), 'Table2'[Month] = SelectedMonth ) ) VAR CountRows1 = CALCULATETABLE( 'Table1', FILTER( ALLSELECTED('Table1'), 'Table1'[Month] = PreviousMonth1 && 'Table1'[Type] = "Task" ) ) RETURN COUNTROWS(CountRows1) Measure works for selected month: VAR SelectedMonth = CALCULATE( MAX('Table1'[Date Rank]), FILTER( ALL('Table1'), 'Table1'[Month] = SELECTEDVALUE('Table2'[Month]) ) ) VAR _tablecalculation = CALCULATETABLE( 'Table1', ALLSELECTED('Table2'), 'Table1'[Date Rank] = SelectedMonth, 'Table1'[Status] = "Not Normal", 'Table1'[Previous Status] = "Not Normal", 'Table1'[Type] = "Task" ) RETURN COUNTROWS(_tablecalculation) Any help in the right direction is definetly appreciated!Solved1.3KViews0likes4CommentsCreate count column visual based on column slicer and column group on x-axis
I am trying to write a measure to create a dynamic visual. I have the following table below as a single table in my file. I want the user to be able to select a month. If the user selects June. Then I want previous month to be used in the measure (This would be May since this is the since 1 + the date rank gives the group of the previous month). Then I want the measure to count the number of rows where multiple filter conditions are met. I want to count rows where Dank rank =2, Status and Previous Status = "Not Normal" and where Type = "Task". So this would return a 1 because there is only one row where all conditions are met. But I want the measure to update based on what the user selects as the current month. If the user does not select a month, then I want to show blank for the measure. Right now, I am able to get the correct count, but when I group the visual by the "Group" column on the x-axis, I get the same number for each group rather than just the count for that specific group. (Table and current dax formula I have is below). Thank you for any help on this. ID Status Date Rank Previous Status Month Type Group A Normal 3 No previous 24-Mar Task <0 B Normal 3 No previous 24-Mar Task 1 to 5 C Not Normal 3 No previous 24-Mar Task 1 to 5 D Not Normal 3 No Previous 24-Mar Not Task 11 to 15 A Not Normal 2 Normal 24-May Task 6 to 10 B Normal 2 Normal 24-May Not Task 6 to 10 C Normal 2 Not Normal 24-May Not Task 6 to 10 D Not Normal 2 Not Normal 24-May Task 6 to 10 A Not Normal 1 Not Normal 24-Jun Task 1 to 5 B Not Normal 1 Normal 24-Jun Task <0 D Normal 1 Normal 24-Jun Task <0 E Normal 1 24-Jun Task 1 to 5 Measure = VAR SelectedMonthRank = CALCULATE( MAX('Table'[Date Rank]), ALLSELECTED('Table'[Month]), ALLSELECTED('Table'[Group]), 'Table'[Month] = SELECTEDVALUE('Table'[Month]) ) VAR PreviousMonthDateRank = SelectedMonthRank + 1 VAR _tablecalculation = CALCULATETABLE( 'Table', FILTER( ALL('Table'), 'Table'[Date Rank] = PreviousMonthDateRank && 'Table'[Status] = "Not Normal" && 'Table'[Previous Status] = "Not Normal" && 'Table'[Type] = "Task" ) ) RETURN COUNTROWS(_tablecalculation)Solved759Views0likes2CommentsTOPN + Others not aggregating properly with Legends
Hello dear Fabric Community! After many years of finding solutions here, it is my time to ask for help 🙂 I am working in a TOPN + Others problem, that is making my head spin. I am creating 3 different measures like this: X Measure= SUMX( SUMMARIZE( 'Original Table', 'Attribute 1 Table'[ID], 'Attribute 2 Table'[ID], "@X", [X]), [@X]). I am calculating X as X = CALCULATE( [Qty], NOT ('Original Table'[Category_1] IN { "Value 1", "Value 2" }), 'Original Table'[Category_2] = "ANOTHER_VALUE" ) I had to create them like this as my totals were not aggregating properly due to some overall quantities being positive, but when used with certain attributes for legends, the sum included some negatives. Anyway, that part seems to be working fine! I also created a Total Qty = X + Y + Z. My model is normalized, so I have a central fact table with lots of values, and a lot of additional dimension tables with details for some attributes. However, when aggregating and due to Power BI limitations on the 60 legends limit, when plotting some of this in a column chart it would not display accurate values. I arrived at the conclusion that I needed to use TOPN + Others for this charts, and possibly limit TOPN to have an overall number of legends on screen less than 60. 20 seems to be a sweet spot. Now comes the challenge! I watched some tutorials and arrived to the conclusion that a measure like this would do the trick: TOPN_ = VAR IDTopN = SELECTEDVALUE('TOP N'[TOP N]) VAR IsOtherSelected = SELECTEDVALUE ( 'Attribute 2 Table'[ID] ) = "Other" VAR tab = CALCULATETABLE ( VALUES ( 'Attribute 2 Table'[ID] ), ALLSELECTED ( 'Attribute 2 Table'[ID]) ) VAR _Rank = IF( ISINSCOPE ('Attribute 2 Table'[ID]), RANKX ( tab, [Total Qty] ) ) VAR TopNValues = SUMX ( TOPN ( IDTopN, ADDCOLUMNS ( tab, "@SumValue",[Total Qty] ), [@SumValue] ), [@SumValue] ) VAR OtherValues = SUMX ( ALLSELECTED ( 'Attribute 2 Table'[ID] ), [Total Qty]) - TopNValues RETURN IF ( IsOtherSelected, OtherValues, IF ( _Rank <= IDTopN, [Total Qty] ) ) Now, with the help of another table with TOPN values I can see my chart and it produces almost the same as [Total Qty]. There is a small difference, that sometimes I have been able to identify as this. If I do a table with Attribute 2 and my Total Qty, X, Y and Z values it looks like this (I have around 20k IDs for this attrbute): Total Qty X Y Z ID 1 ID 2 ID 3 ID 4 ID 5 ID 6 ... ... ... ... ... TOTAL 1 000 000 500 000 200 000 300 000 Imagine some values there that end up adding to the respective quantities. However, if I add my TOPN Qty, I get a slightly less qty, maybe something like 998 400. So I've been looking at the data and noticed that some of the "Attribute 2" ID's have negative values. I Filtered my table to display only Total Qty < 0 and see something like this: Total Qty X Y Z ID X - 900 - 500 - 100 - 300 ID Y - 700 - 400 - 200 - 100 Totals -1600 - 900 - 300 -400 And those are exactly my missing QTY from TOPN. So I have the following questions. Am I doing something wrong during the calculations that is somehow excluding the values for these negatives while calculating my measures, X, Y and Z? Am I doing something wrong during the calculations that is removing the conditions on X, Y and Z when doing the Total Qty or the subsequent TOPN + Others? Additional to this, I noticed that if my TOPN value is 5, and if I do some other aggregation on the column chart like, month or year, most values look OK (X, Y, Z are time dependent) and there's always an error with current month/year/Qtr (which is the one above). However, If I change my TOPN to 10, 15, or 20, I will also see some additional months/qtrs/years start to have issues. I was thinking this was due to the additional number of labels and for this I have not been able to identify any data points that might cause it, since even selecting 25 as my value does not increase my total number of legends to above 60. If additional details are needed, let me know. This has been giving me headaches for a bit now. Thank you!Solved1.2KViews0likes4CommentsFilter Slicer based on value on another slicer seems not work on me (a bug?)
Hello Power BI community, So here is the situation, I wanted to filter the date so that if I choose either "MTD" or "YTD", the date filter will be turned off. Only when I select "Period" will the date filter can be used. I followed some YouTube tutorials like: or and they provide a quite straightforward way to do it. So, what I did is I created a measure as follow: CustomDateDisable = INT(SELECTEDVALUE('MTD or YTD'[MTDORYTDORPERIOD])="Period") The measure seemed to work well for me. Proved by the value of the CustomDateDisable card: The problem came when I tried to put the CustomDatefilter measure on Date filter. The date filter seems to ignored the MTDORYTDORPERIOD value and only depends on how I choose the value on the CustomDateDisable pane. I really appreciate if there is someone to correct my logic or the implementation to this case. Thank you in advance. [UPDATE] Hey Power BI community, I update the case for an important context. It seems that I encountered some type of bug. When I changed the field to something other than Date, the filter worked perfectly to disabled the slicers. Also, the filter still worked fine when I changed the field to date, but the style I choose was vertical list or tile Only when I change the style to between, before, after, dropdown, relative date, or relative time, that the filter start to not working. Hopefully anyone on this forum can notice. Thank you in advance.676Views0likes2Comments