distinct
29 TopicsDynamic DAX Measure to Count Distinct Rows filtered by separate query
Hi All, I'm pretty new to DAX and struggling to figure this out so any help is greatly appreciated. I have the following data model (simplified): I am trying to write a measure that runs a distinct count on the number of students ('Enrolment'[Student ID]) that have attended an appointment ('Appointments'[Attendance Status]=2). I then want to be able to slice on this measure by date, dimensions etc. The following is currently giving me the correct total over all my data: # Appointment Attendees (Distinct Students) = CALCULATE ( DISTINCTCOUNT('Enrolment'[Student ID]), FILTER(ALL('Appointments'), 'Appointments'[Attendance Status] = 2) However I have a number of other slicers in my report, drawing on values from fact and dim tables. These slicers are not working with the measure in the report , it only displays the original value. Is there a way to re-write the measure so it still works dynamically with slicers? Thanks in advance for your help.Solved1.1KViews0likes2CommentsData Table Creation with FILTER DISTINC and COUNT
I have a table A: ID AGEMO BINDER 1 1 0 2 1 1 3 6 0 4 8 0 8 21 0 and I created a second table (TABLE B) from the following command: ID Target = distinct('Table A'[AGEMO]) This creates this Table B: AGEMO 1 6 8 21 In column B I need to add an additional column that counts the ID's from table 1 that correspond to each AGEMO but only to do that if BINDER=0 to give me the following in Table B: AGEMO COUNT ID 1 1 6 1 8 1 21 1 I was using this formula to do that: COUNT AGEMO = countrows(filter(relatedtable('TABLE A'),'TABLE A'[BINDER]=0)) But instead of giving me the table I want above its giving me the following table: AGEMO COUNTID 1 4 6 4 8 4 21 4 Where 4 is just the total number of BINDER=0 animals in TABLE A instead of relating them to the actual AGEMO they should be with. Can someone help me with this?Solved597Views0likes2CommentsDistinct Count based on calculated percentage measure
I have a table with hundreds of thousands of rows for individual sales, but each sale is designated to a specific group. I have a slicer that selects the desired reporting period (end date) and then I can calculate the total sales for the rolling-12 months based on the selected date both for the national total and each group. Finally, I have created a measure that shows the percent contribution to the nation for each group during the selected time period (Group Sales %). This all works great. What I'm struggling with is getting a simple distinct count of the number of groups whose percent contribution (Group Sales %) is > 1%. See the screenshot below which shows the list of group sales percents, and the distinct count measure I've written. You can see that it's counting each group once, without being filtered by the measure. How can I change this measure to correctly count ONLY the groups where Group Sales % >= .01? The resulting card should show 19, not 92 (which is the count of ALL groups).Solved1.1KViews0likes3CommentsCalculate Years of Policy Retention
I would appreciate any assistance to create a new measure to calculate the years of policy retention by policy number for the following sample data. For each unique policy number, there may be several transactions entered for a particular policy year, but I would like a total count of each unique effective date for each policy number. In this sample data, I would expect 2875 to return a count of 3, 3294 would return a count of 4 and 7236 would return a count of 4. Policy Number Effective Date Transaction Amount 2875 2/1/2020 $ 20.00 2875 2/1/2020 $ 30.00 2875 2/1/2020 $ 25.00 2875 2/1/2021 $ 45.00 2875 2/1/2022 $ 50.00 3294 4/15/2021 $ 22.00 3294 4/15/2022 $ 13.00 3294 4/15/2022 $ 72.00 3294 4/15/2022 $ 55.00 3294 4/15/2023 $ 30.00 3294 4/15/2023 $ 45.00 3294 4/15/2024 $ 60.00 7236 2/1/2018 $ 19.00 7236 2/1/2019 $ 43.00 7236 2/1/2019 $ 23.00 7236 2/1/2019 $ 25.00 7236 2/1/2020 $ 40.00 7236 2/1/2020 $ 17.00 7236 2/1/2021 $ 5.00 7236 2/1/2021 $ 64.00 As different policy numbers may have the same effective dates, I cannot simply count distinct effective dates and compare to distinct policy numbers. I am not concerned with gaps in effective dates as if there is a gap the policy number would also change. I will be utlizing this data to provide average policy retention periods on simple cards for avariety of other statistics (such as state, coverage type & profession).Solved563Views0likes1CommentSum of column A' values based on distinct values in column B
Dear I got a problem when calculate the distinct sum value. I want to get the sum value of different "category" based on the distinct value in column "Time", which means I want the value"sum technical =60+15","sum External = 20+10". I have try this DAX " Technical-Distinct = calculate( sum('Test'[Value]), 'Test'[Category]="Technical", distinct('Test'[Time]) ) " But it seems didn't work.😠Anybody could help that? Very appreciate it! ID Category Value Time 1 Technical 60 8/25/2023 11:00 2 Technical 60 8/25/2023 11:00 3 Technical 60 8/25/2023 11:00 1 External 20 8/25/2023 11:00 2 External 20 8/25/2023 11:00 3 External 20 8/25/2023 11:00 4 Technical 15 9/15/2023 17:00 5 Technical 15 9/15/2023 17:00 4 External 10 9/15/2023 17:00 5 External 10 9/15/2023 17:00Solved1.3KViews0likes5CommentsSUM column based on distinct ID
Hi all! I cant seem to figure out the following (which looks very straightforward) I have a dataset which shows how much meter a category has in a store. The data set has rows for each article within a category, but the 'Length of Category' column is based on the total of that category. For example, in store 1, the Bread Category has 2,0 meter of space. Store ID Category Article Length of Category (in meters) 1 Bread White 2,0 1 Bread Brown 2,0 1 Drinks Water 4,0 1 Drinks Soda 4,0 For the example above, if I sum how much total meters store 1 has, it will add up to 12,0 (2+2+4+4), but I need it to be 6 (2+4). As I dont want the categories to double. What is the correct way of doing this through dax? I cant seem to google it or figure it out and I feel like it's quite easy. Help is much appreciated!Solved636Views0likes2CommentsDistinct Count for a card visual based on a measure (Visual Level Filter)
Hi, I have created a measure - "Measure1". I have created a table visual with Measure1 applied as a visual level filter with values > 1. Screenshot below: Now I am trying to create a CARD visual showing the count of Drivers that is shown in the above table. But the card visual does not accept a measure as a visual level filter. Count of Distinct Drivers = DISTINCTCOUNT('Table'[Driver Name]) So, I am trying to figure out a DAX measure that would solve this. Any help will be appreciated.757Views0likes1CommentCount Distinct Measure at lowest level
Hi!, Im struggling with this measure, Im not getting the result I want, I have this table: sale_id sale_type person 1 1 a 2 1 b 3 2 c 4 2 x 5 2 y 6 2 z 7 3 a I want a measure that calculates the distinct count of person for each sale_type, the result should be like this: sale_id sale_type person Distinct_Person_Per_Sale_Type 1 1 a 2 2 1 b 2 3 2 c 4 4 2 x 4 5 2 y 4 6 2 z 4 7 3 a 1 This measure works but only If I not add the sale_id to the table: Distinct_Person_Per_Sale_Type = CALCULATE( DISTINCTCOUNT('Table'[person]), ALLEXCEPT('Table','Table'[sale_id],'Table'[sale_type]) ) How can I achieve that the measure works at the lowest level of the table (sale_id)? thanks a lot for your guidance and help!Solved1.4KViews0likes7CommentsCount distinct name_id
I have the date table and name_id and phases. Each column represents a day for name_id and a Phase. I would like to graph the number of name_id by Phase or month. I tried to distinguish name_id, but when a name_id changes phase along the month it ends up being counted twice on that month. Each color means a phaseSolved1.9KViews0likes2CommentsCount Number of Bundles sold based on Invoice number.
Hello, I am trying to setup a measure in Power BI that counts the number of a specific bundle that is sold at my company. I have an invoice data table along with a product table and I want to count how many times we sold the combination of "A, B, and C" Product Components on each unique invoice. In the below table the correct answer would be 2 because we have 3 positive occurrences of the bundle and 1 negative occurrence indicating a returned bundle. There are also situations where there may be 2 bundles sold on one invoice, or multiple of one item but you can only classify 1 "bundle" because the other items only have 1 unit each. Please let me know if you need more information to assist with this since I am relatively new to DAX. I greatly appreciate any assistance. Invoice Product Component Units 111 A 1 111 B 1 111 C 1 111 D 1 222 A 2 222 B 3 222 C 2 333 A 1 333 C 1 333 X 1 333 V 1 444 B 1 444 A 1 444 V 1 555 A -1 555 B -1 555 C -1Solved6.8KViews0likes28Comments