aggregation
27 TopicsWrong Totals in aggregation snapshot tables
Guys, I need your help. I'm stacking up 2 snapshot tables, and, besides I'm using sumx with some help of copilot, I'm getting the wrong totals. I'm trying to get the right numbers of enrollment for each period of time based on CICLO column. Here is an example of this table, DATA_MATRICULA is primarykey to datatable: DT_EXECUCAO_AGG| MAT_LIQ| CICLO| DATA_MATRICULA 20/05/2025 1 20242 10/05/2024 20/05/2025 3 20242 11/05/2024 20/05/2025 5 20242 12/05/2024 20/05/2025 0 20242 13/05/2024 20/05/2025 9 20242 14/05/2024 20/05/2025 9 20242 15/05/2024 20/05/2025 30 20252 10/05/2025 20/05/2025 10 20252 11/05/2025 20/05/2025 1 20252 12/05/2025 20/05/2025 3 20252 13/05/2025 20/05/2025 5 20252 14/05/2025 20/05/2025 1 20252 15/05/2025 04/06/2025 0 20242 10/05/2024 04/06/2025 1 20242 11/05/2024 04/06/2025 3 20242 12/05/2024 04/06/2025 5 20242 13/05/2024 04/06/2025 2 20242 14/05/2024 04/06/2025 2 20242 15/05/2024 04/06/2025 1 20252 10/05/2025 04/06/2025 0 20252 11/05/2025 04/06/2025 20 20252 12/05/2025 04/06/2025 5 20252 13/05/2025 04/06/2025 1 20252 14/05/2025 04/06/2025 1 20252 15/05/2025 Here some example of what I want to show RĂ³tulos de Linha 20242 20252 Total %YoY Campus 13 62 75 377% Polo 27 16 43 -41% Total Geral 40 78 118 95% This measure is looking to get the quantity of enrollment from the same period of the last year, but I used a fixed timeslap 365 days back. Sum MAT_LIQ_AA_YTD_Foto_D-1 = VAR CicloPassado = CALCULATE(MAX('f_MYTABLE_252'[CICLO])) - 10 VAR MaxExecucao = CALCULATE(MAX('f_MYTABLE_252'[DT_EXECUCAO_AGG])) RETURN SUMX( VALUES(d_Datatable[Date]), VAR DataContexto = d_Datatable[Date] VAR DataDeslocada = DATEADD(d_Datatable[Date], -IF(DataContexto < DATE(2025, 03, 01), 366, 365), DAY) VAR MaxData = CALCULATE(MAX(d_Datatable[Date]), ALL(d_Datatable)) RETURN IF( DataContexto <= MaxData, CALCULATE( SUM('f_MYTABLE_252'[MAT_LIQ]), 'f_MYTABLE_252'[CICLO] = CicloPassado, 'f_MYTABLE_252'[DT_EXECUCAO_AGG] = MaxExecucao, d_Datatable[Date] = DataDeslocada ), BLANK() ) )Solved935Views0likes5CommentsAggregating over date in a measure
Hello, I want to build a measure which shows the number of days people login to their account per month, quarter, year. The data is in this format - with user ID, login date. I then create end of month and end of quarter in query view and create "Days with a login (month)" and "Days with a login (quarter) as calculated columns using the DAX below. Days with a login (month) = CALCULATE ( DISTINCTCOUNT ( 'Login activity'[Login date] ), ALLEXCEPT ( 'Login activity', 'Login activity'[User Id], 'Login activity'[End of Month] ) ) Days with a login (quarter) = CALCULATE ( DISTINCTCOUNT ( 'Login activity'[Login date] ), ALLEXCEPT ( 'Login activity', 'Login activity'[User Id], 'Login activity'[End of Quarter] ) ) I then do a distinct count of user ID to build the visuals below. Can someone help me with the dax to build the measures which allow me to build the above visuals but without the need for multiple visuals and calculated columns? So I want to use the dates hierarchy from my dates table on the x-axis (so I can drill up and down) and then build measures for number of people who have logged in on 1 day, 2 days, 3 days etc. So I will have multiple measures which work using my dates table and no calculated columns. Thank you in advance đŸ™‚Solved1KViews0likes2CommentsCorrect 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.4KViews0likes9CommentsAgg after recent date
Hi everyone, I have this table below that is connect to a Calendar Table. Date ID Column1 Column2 31/07/2021 A 160 1060 31/08/2021 A 200 1170 30/09/2021 A 175 1300 31/07/2021 B 10 150 31/08/2021 B 12 200 30/09/2021 B 14 250 I want to calculate two metrics. They have to show the most recent result, that is defined by a slicer based on the Calendar Table. The metrics are: Total amount of column1 Total amount of column2 I am struggling with getting the most recent result. Let's say that my slicer goes from 1/Jun/2021 to 15/Sep/2021 I want a card that shows me: Col1_A + Col1_B = 200+12 = 212 Col2_A + Col2_B = 1170+200 = 1370 Any ideas on how to lock the most recent available value and then sum per ID? ThanksSolved671Views0likes2CommentsHow to add totals from chart together down X axis
Hello I have a chart of total sales by date difference. I want to aggregate across the x axis as it moves to the left. For example, date 0 has 155, and date 1 has 108. So I would want date one to show the combined amount of 263 (155+108). This would continue across the chart and increase. How would I do that with dax?Solved668Views0likes2CommentsNormal Distribution on Aggregated Values using Average for Last 5 Years
Hi All, I am trying to replicate an Exel formula based on Normal Distribution as a Measure in Power BI. In Excel this formula is used on aggregated values of Year and Region. In Power BI I want the formula to work on the unaggregated dataset to avoid having to create and work off a new table. The formula is as follows: NORMDIST(X, avg(last 5 yrs), SD (last 5 yrs) * 1.5) * 100 Where X is the value I want to see where it sits on the distribution. The data (simplified) is as follows: Record No. Category Allocation Approval Year Region 1 A 1 Yes 2020 South 1 B 1 Yes 2020 South 2 C 1 No 2020 North 2 D 1 No 2020 North 3 A 1 No 2022 West 3 D 1 No 2022 West 3 E 1 No 2022 West Records can be assigned multiple categories and these have been pivoted to show one category per row. Because of this the Allocation column is always 1. I would like the equation to be a single measure so I can easily switch between this and the sum of allocation/approval measures I already have. I would want the output to look something like this: Year A B C D E 2020 > 43 56 48 71 28 South 28 56 45 24 58 North 68 15 47 49 57 West 57 58 25 47 85 2021 62 50 48 69 42 2022 56 47 32 58 45 Thanks in advance!557Views0likes1CommentAggregated values directly at the last rows of TABLE visuals
Hi, Being a newbie requesting help to get the aggregated values below the "total" row generated from TABLE visual. Unable to use MATRIX visual as i need to show the aggregated values below the total(sample representation as below).Will use the same for Date wise as well as month wise ,year wise slicer. Data Set Sample as below: Also i have created Aggregated Table using Power query which is available as a data set: Also have created measures on values for each measuing point separately which is used for other graphical visuals. Deeply appreciate forums support to meet the objective. Thank you.Solved1.1KViews0likes5CommentsMeasures 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.2KViews0likes4CommentsMeasure 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.2KViews0likes5CommentsSum up all positive and all negative
Hi everyone, I am attempting to create a sum of all positive and all negative changes of sales values. My base table looks as follows: Account Year Sales A 1 10 A 2 15 B 1 10 B 2 6 C 1 10 C 2 10 D 1 10 D 2 11 E 1 10 E 2 9 As you can see, sales of accounts A, B, C, D and E between year 1 and 2 have changed as follows: Difference A 5 B -4 C 0 D 1 E -1 Which means that in total, we have a positvie sales difference between year 1 and 2 of 6 (=5+1) and a total negative sales difference of -5 (=(-4)-(-1)). I have created the first difference by creating a measure that looks as follows: var salesPY= CALCULATE( sum('Salestable'[Sales]), FILTER( 'Salestable', 'Salestable'[Year] = 1 ) ) var salesCY= CALCULATE( sum('Salestable'[Sales]), FILTER( 'Salestable', 'Salestable'[Year] = 2 ) ) return diff= salesCY - salesPY Due to the presence of slicers and more details in the original table, I am not able to sensibley use a calculated column here. Can anyone tell me, how to aggregate all positive/negative sales differences together, so I get 6 and -5, respectively? Thank you for your help in advance!Solved725Views0likes2Comments