aggregation
27 Topics[SOLVED] Getting correct sums from unpivoted table in star schema
Hi everyone, I'm having some difficulty with a new dashboard I'm working on. This is my first time implemenenting a star schema but I have one central "fact" table surrounded by "dimension" tables, linked with unique keys. I have several columns of survey data in the fact table that need to be unpivoted but this is causing duplicates of all the other value fields in the fact table. Here is a mock up of my starting data: ID Value Survey1 Survey2 1 10 1.1 2.1 1 10 1.11 2.11 2 20 1.2 2.2 And here it is after the unpivot: ID Value Survey Answer 1 10 Survey1 1.1 1 10 Survey2 2.1 1 10 Survey1 1.11 1 10 Survey2 2.11 2 20 Survey1 1.2 2 20 Survey2 2.2 As you can see, after the survey columns are unpivoted, there are duplicate values in the value column. So, for example, if I want a card that shows the sum of an ID's value column, its much bigger than it should be. How do I work around this without creating another table and ruining the star schema? Happy to provide more context, thanks!Solved3.6KViews0likes5CommentsImplement Aggregate Sum column based on values from other columns
Hello All I wish to implement a column D as shown in below screenshot using DAX measure such that Column D aggregation is sum of values in Column C. For Example, Value in Row number D3 is sum of values from Rows C3 to C8 such that it is aggregated on same supplier value from Column A from row A3 to A8 and the sum in row D3 must also correspond to MDF in row B3 with highest value in row C3. Is this possible to achieve in Power BI table visual using DAX ??Solved3.4KViews0likes4CommentsAggregate Measure correctly by condition on DATEDIFF
I have the following Table: It represents processes with a certain category. And there is also a Date Table over column TIMESTAMP. I would like to show a Measure based on another Measure that calculates the Date-Difference until the selected Date. So first this is how I calculate the Date-Difference: AGE = VAR SELECTED_DATE = CALCULATE(MAX(DATUM[Date]), ALLSELECTED(DATUM)) VAR STARTDATE_PROCESS = Calculate(MAX(Workflow[MIN_TIMESTAMP]),DATUM[Date]<=MAX(DATUM[Date]), ALL(DATUM[Date])) RETURN DATEDIFF(STARTDATE_PROCESS,SELECTED_DATE,DAY) Now I want to use a Measure which depends on the result of AGE, like NEW = IF([AGE]<=3,CALCULATE(COUNT(Workflow[PROCESS]),ALL(DATUM))) or OLD = IF([AGE]>3,CALCULATE(COUNT(Workflow[PROCESS]),ALL(DATUM))) That works so far, but the aggregation is not working correctly as you can see here, there should be a 3 on NEW and OLD aggregated: Any idea how to fix that? Thank you!Solved1.8KViews0likes4CommentsUnwanted Aggregation with dynamic Ranking
Hi, I am trying to create a dynamic ranking measure. Lets say I have n rows after every filter operation. Now I want the rows enumerated from 1.. n, according to their original id (which is unique). link to pbix <- here is a reproduction of the error. Password: Example%5 I tried the solution by @Eirc_Zhang from this post but it does not work for me. Here is the code how I modiefied it, to use the index as the parameter for ranking. RankID = MINX ( FILTER ( SELECTCOLUMNS ( ALLSELECTED ( ParentData ); "index"; ParentData[Index]; "rank"; RANKX ( ALLSELECTED ( ParentData ); ParentData[Index];; ASC; DENSE ) ); [index] = MAX ( ParentData[Index] ) ); [rank] ) Everytime I use a visual with non unique field combinations, the rows are aggregated, as you can see in Visual (1) in my posted image. In Visual (2) the unique field "Index" is added and then there is no aggregation. The final goal would be to use a non unique field and the RankID togehter in a scatter plot (Visual 3). Since you can't add there another field there would be always an unwanted aggregation. Can someone help me to fix the problem? (I already managed to do it with a python visual, but I would rather have an interactive visual. I kinda wish, I could use python to calculate measures ) I actually don't fully understand the linked solution and would appreciate, if someone could help me to understand it a little better. For example I have a hard time to understand how the MINX function works, since the inner filter call just returns a table with a single row as output, as you can see in the next image. Best regards, AndreasSolved1.7KViews0likes4CommentsPerformance Tune Summarize function to GroupBy Function with Filters
Hello, I'm running a summarize function that is wrecking my performance - I read that Group By can give me an advantage in this regard but I'm unsure how to use both Group By and Filter. here is my current code: var last_date = lastdate(CONFORM_MOVEMENT[BusinessDate]) VAR max_on_hand_calc = SUMMARIZE(CONFORM_MOVEMENT,CONFORM_MOVEMENT[Store], CONFORM_MOVEMENT[ItemNumber],"max_on_hand", CALCULATE(Max(CONFORM_MOVEMENT[TotalonHand]), FILTER(ALL(CONFORM_MOVEMENT[BusinessDate]), CONFORM_MOVEMENT[BusinessDate] > last_date - max(CONFORM_MOVEMENT[ideal_doh]) && CONFORM_MOVEMENT[BusinessDate] < last_date))) Any suggestions on what could be limiting the performance of measure and how to go about converting to Group By over Summarize? Thank you, ChanningSolved1.6KViews0likes3CommentsCorrect Total using ALL() whilst also having blanks filtered out of visual?
Hi I'm hoping someone may have a quick solution to a problem i'm encountering whilst trying to provide % of total in a bar chart. The screenshot below shows a dummy dataset for customer feedback replicating the issue i'm encountering. The data spans over 3 days (20th Oct to 22 Oct), with a total of 25 customers, 9 of which opted not to give feedback. I'm needing to present this data as a % broken out by feedback score. I have used the 'feedback%' measure shown below, which leverages the ALL() function to clear the feedback_rating filter, providing a total customer count. You can see from the 2nd bar chart that this works when the blank feedback rating option is included in the visual. Example feedback score of 1 has 5 customer entries, 5/25 = 20%. I have been asked to remove blanks from the visual. When these are removed however, the % are incorrect as can be seen within the red bar chart, a feedback score of 1 now has a % distribution of 26%. The reason appears to be due to the Date slicer which is required in my real dashboard. As all the customers on 21st October did not leave feedback, I believe when the blanks are removed from the visual, all of these rows are removed from the underlying data, creating a new customer total of 19, resulting in incorrect %'s, feedback score of 1 now becoming 26% (5/19) as mentioned above. Any ideas on how to keep these values in the total whilst also keeping the blank entries out of the visual? Ideally I would like to solve it within a DAX measure as my existing dashboard already has a relatively complex data model, however I appreciate it may require a helper table of some sort. feedback% = distinctcount(Sheet1[customer_id]) / CALCULATE(DISTINCTCOUNT(Sheet1[customer_id]),ALL(Sheet1[feedback_rating])) Thanks for reading.1.4KViews0likes9CommentsMeasure for aggregation & range values
Hello, From a source table like: Date Id Hours 01/01/2020 A 10 02/01/2020 A 8 03/01/2020 A 9 04/01/2020 B 7 05/01/2020 B 10 02/02/2020 A 11 03/02/2020 A 4 04/02/2020 B 3 05/02/2020 C 6 15/03/2020 A 8 16/03/2020 B 3 17/03/2020 C 2 18/03/2020 C 15 I'm trying to get a table with the count of Ids per Month and Id, clasified by range of values, so I'd end up with this: Month Ids whose monthly Sum Hours < 10 Ids whose monthly Sum Hours >= 10, <20 Ids whose monthly Sum Hours >20 Jan 1 1 Feb 2 1 Mar 2 1 I'm trying to figure out the measure(s) to get this, could you guys help, please? ThanksSolved1.2KViews0likes5CommentsAggregate a calculated count for each day over a period
Hi I'm working with a table a bit like this: User Logins ID Timestamp 1 21/09/2022 00:00:00 4 20/09/2022 00:00:00 1 20/09/2022 00:00:00 ... ... I have chosen to categorize a group of users as "Active Users", as the ones which has been logged in the past 14 days. So, I can retrieve all my "Active Users" by using this Measure: CALCULATE(DISTINCTCOUNT('User Logins'[ID]), 'User Logins'[Timestamp] > TODAY()-14) But - here's my problem. I want to create a graph of "Active Users" for the past 7 days. So I need to somehow replace "TODAY()" with "Whatever X-day is showed on the x-axis on the graph". Just to make it more clear, maybe we have the following results of the count: Count of unique ID's Date 10 21/09/2022 15 20/09/2022 5 19/09/2022 7 18/... 4 17/... 7 16/... Then I would like to get the following result (just displayed in a graph instead): Count of unique ID's the past 14 days Date 82 (10+15+5+7+4+7+...) 21/09/2022 89 (15+5+7+4+7+...) 20/09/2022 75 (5+7+4+7+...) 19/09/2022 78 (7+4+7+...) 18/09/2022 I hope it makes sense and that someone knows the necessary formula! 🙂 /VladSolved1.2KViews0likes3CommentsMeasures to aggregate by month & range values
Hi all, My data table is something like: Im asked to get a table/histogram with a row/bar per month and the number of IDs per range of summatory of hours/month: Here is an intermediate table to help you guys understand the requirement: Is it possible to get it with just with measures/DAX and not having to create the intermediate tale in the data model?? Thanks a lot in advance!Solved1.2KViews0likes4CommentsDynamic Agregation - hardest so far
Hey guys, I am struggling with one of the hardest mind games I have encountered in DAX so far. I have a data set that can be pivoted to cohort table like this: Sum of EndingMRR YearsActive Row Labels 0 1 2 3 4 5 2020-01 8,000 7,000 7,000 6,800 7,800 7,500 2020-02 16,000 15,000 13,000 12,000 12,000 2020-03 5,000 4,300 4,000 4,000 2020-04 7,000 7,500 7,500 2020-05 14,000 14,100 Grand Total 50,000 47,900 31,500 22,800 19,800 7,500 I would need to divide MRR from each active year with their base from zero year - i.e. I would need to get retention % of all those customers that are active for a certain number of years. (for example numbers in orange: for 4th year that would be 19,800 divided with only the sum of orange numbers from zero years that is 24,000 and I would get 82.5%; for 5th year that would be 7,500 divided by only 8,000 from zero year etc) I have tried to do it with the following formula = DIVIDE ( SUM ( CustomerData[EndingMRR] ), CALCULATE ( SUM ( CustomerData[EndingMRR] ), ( CustomerData[YearsActive] = "0" ) ) ) but this is wrong because it is taking the sum of all the numbers from zero year instead of only specific ones. Using excel to show you the logic and the outcome: Please help! Any advice is welcome. I appreciate your help guys! Thank you!Solved1.2KViews0likes3Comments