summarize
113 TopicsHow SUMMARIZE works and does it create a row context?
I have this employee sample dataset, fact table is Employees: emp ID BU Days 1 1 0 1 1 30 1 1 60 2 1 0 2 1 30 3 1 0 3 1 30 3 1 60 3 1 90 4 2 10 4 2 20 5 2 10 5 2 20 5 2 30 I want to get average days per business unit (BU), but since each employee has repeated records, I want to use the record with maximum number of days to express working days of each employee. I used the below in DAX query view: Note: T1 is intermediate to group for max days. T2 is the target, but returned wrong results: average over all T1, not average grouping over BU! T3 and T4 returned correct results. Why did T2 fail? Why it did not create [BU] row context and group on it like T1 did with [emp ID] EVALUATE VAR T1 = SUMMARIZE( Employees, Employees[emp ID], Employees[BU], "MaxD", MAX( Employees[Days] ) ) VAR T2 = SUMMARIZE( T1, Employees[BU], "AvD", AVERAGEX( T1, [MaxD] ) ) VAR T3 = ADDCOLUMNS( VALUES( Employees[BU] ), // SUMMARIZE(Employees, Employees[BU]) also works here in place of VALUES() "AvD", AVERAGEX( FILTER( T1, Employees[BU] = EARLIER( Employees[BU] ) ), [MaxD] ) ) VAR T4 = GROUPBY( T1, Employees[BU], "AvD", AVERAGEX( CURRENTGROUP(), [MaxD] ) ) RETURN T4Solved1.5KViews0likes5CommentsCalculate percentile between tables
Hi all, I have two related tables in my Power BI model: 📁 Table 1: "Reportes uso ChatGPT" Contains usage data per employee: "Fecha" (Date in dd/mm/yyyy, representing the month) "email" (employee's corporate email) "messages" (number of ChatGPT iterations that user performed in that month) ➡️ A user can appear multiple times (one row per month of usage). 📁 Table 2: "Datos demográficos" Contains unique employee information: "ID" (employee identifier) "Dirección email trabajo" (corporate email address) ➡️ This table has one row per employee. 🔗 Relationship: There's a one-to-many relationship: From "Datos demográficos"[Dirección email trabajo] To "Reportes uso ChatGPT"[email] ✅ What I need: I want to create a DAX measure that calculates the percentile of each employee based on their total ChatGPT usage (messages), across all employees in the company, including those who: have no usage at all, have never appeared in the usage table, or have zero messages. The idea is that: Employees with more messages get a higher percentile (100% = highest usage), Employees with less or no usage get lower percentiles (down to 0% = no usage). 💡 Ideally: I’d like to do it in separate DAX measures so I can use it for other measures: Total messages per employee Ranking among all employees (based on total messages) Percentile normalized between 0 and 100 📌 Note: I'm open to using TREATAS, RANKX, or virtual tables (ADDCOLUMNS, SUMMARIZE, etc.) if necessary. Any ideas or recommended approach to achieve this? Thanks in advance! 🙏Solved1.2KViews0likes6Commentscombinatorics in dinamic dax
Hello guys, i have posted here so many times about getting a logic right, but i just noticed it was impossible, in the way i was thinking, no one could help me. I have a new aproach of how to get the desired result, its by using combinatorics, of course, i need to know if its even possible in the dax. I have the image bellow that shows how the combinations might work, and ahead i also have the code i'm trying, its not working properly and i would like some help with it. In this code, the objective is have at the end the combinations that attend to the condition that the amount of concatenated orders is the highest and the sum of values are <= 21. Obs. this code might work with many different products, but to this example i just used one. Code: FinalCorrectStatus = VAR CurrentItem = SELECTEDVALUE('DB_ORDERS'[Produto]) VAR OrdersTable = FILTER(ALL('DB_ORDERS'), 'DB_ORDERS'[Produto] = CurrentItem) VAR OrderCombinations = ADDCOLUMNS( GENERATEALL( OrdersTable, SUMMARIZE( OrdersTable, 'DB_ORDERS'[Pedido], "Soma_Quant_Falta", SUM('DB_ORDERS'[QT. falt]) ) ), "PedidosConcatenados", CONCATENATEX(OrdersTable, 'DB_ORDERS'[Pedido], ", "), "Qtd_Pedidos", COUNTROWS(OrdersTable) -- Conta o número de pedidos na combinação ) VAR FilteredCombinations = FILTER(OrderCombinations, [Soma_Quant_Falta] <= 21) VAR MaxPedidos = MAXX(FilteredCombinations, [Qtd_Pedidos]) -- Encontra o maior número de pedidos VAR BestCombination = FILTER(FilteredCombinations, [Qtd_Pedidos] = MaxPedidos) -- Mantém apenas a combinação com mais pedidos RETURN BestCombination Can anyone please help me with it?Solved1.3KViews0likes5Commentslogical error in dynamic filtering for calculated tables using summarize
Hi All I have created a measure using summarize which dynamically calculates a list for last year and this works fine for all the filters. Still, i am unable to filter it dynamically using the column u have created the filter for(Append1[CustomerList_Filtered]). if i insert Append1[CustomerList_Filtered] in the Allexcept condition i am getting an error "The column 'CustomerList_Filtered' specified in the 'SUMMARIZE' function was not found in the input table." VAR My_table = SUMMARIZE ( FILTER ( ALLEXCEPT( Append1 , Append1[Service Centre Name], Append1[Channel V1] , Append1[NSO] , Append1[CustomerOrganisation], Append1[Month No] ) , Append1[StatusDateTime] >= start_Date_LY && Append1[StatusDateTime] <= End_Date_LY ) , Append1[CustomerList_Filtered], "Accepted Jobs2", [Accepted Jobs.AG], "Accepted Revenue2", [Accepted Sales.AG] )Solved1.9KViews0likes11CommentsDAX Summarize By Employee With Formula
I have a table like this that computes the Quota Impact by this formula. ([Quota]/([Days in Month]*8))*[Hours Closed]. It works fine when all the rows of the table are selected in the Visual. However I'm trying to group this by Employee, but it sums the Quota Amount for each location and then computes, which is expected, but I'm not certain how to calculate it something like [Quota] divided by Count by Location given there could be an entry in two different months . Summary it should look like this Bob =44/248 * 16: Emp Quota Impact Bob 2.82 Suzy 1.04 Instead I get : Bob=88/248 * 16: Emp Quota Impact Bob 5.67 Suzy 2.08 Location Quota Date Hours Closed Emp QuotaImpact Location A 44 9/1/2024 8 Bob 1.41 Location A 44 9/1/2924 8 Bob 1.41 Location B 12 9/1/2024 8 Suzy 0.38 Location C 13 9/1/2024 8 Suzy 0.41 Location C 16 10/1/2024 4 Suzy 0.25Solved665Views0likes2CommentsDax to divide 2 columns based on fixed values
Hello Enthusiasts I have a below input table Bucket TOS Bucket LM TOS LM B1 1 B0 3 B1 2 B0 4 B1 3 B1 5 B2 4 B1 6 B2 5 B2 7 B3 6 B3 8 I need the below Output table Bucket % B1. 0.85 ( sum of TOS for bucket B1(1+2+3=6)/sum of TOS LM FOR bucket lm B0(3+4=7) B2. 0.81 ( sum of TOS for bucket B2(4+5=9)/sum of TOS LM FOR bucket lm B1(5+6=7) B3. 0.86 ( sum of TOS for bucket B3(6)/sum of TOS LM FOR bucket lm B2(3+4=7) Thanks in advanceSolved816Views0likes3CommentsDAX equivalent of GROUP BY and MIN - How do I count products launched, by year?
I want to create a measure that counts how many products were sold for the first time in a given year. That means if the product was sold in any year prior, it should not count in the current year. I would expect to do something like this: (code can be run and iterated here: [https://dax.do/fDTAmTl3kDIMaF/][1] ) DEFINE MEASURE 'Sales'[m1] = CALCULATE ( DISTINCTCOUNT (Sales[ProductKey]), SUMMARIZECOLUMNS ( Sales[ProductKey], CALCULATETABLE ( Sales, ALL( Sales[Order Date] ), ALL( 'Date'[Date] ), ALL( 'Date'[Calendar Year] ) ), "earliest_sale", MIN( Sales[Order Date] ) ), ALL( Sales[Order Date] ), ALL( 'Date'[Date] ) ) EVALUATE SUMMARIZECOLUMNS ( 'Date'[Calendar Year], "number of products sold for the first time", 'Sales'[m1] ) However, this returns the following: Which is exactly the same result as the one I get from EVALUATE SUMMARIZECOLUMNS ( 'Date'[Calendar Year], 'Sales', "distinct product sales", DISTINCTCOUNT ( Sales[ProductKey] ), "total sales", COUNTROWS ( 'Sales' ) ) Finally, going perhaps, a little bit crazy, I tried this: EVALUATE SUMMARIZECOLUMNS ( 'Date'[Calendar Year], FILTER( 'Sales', Sales[Order Date] = CALCULATE( MIN( Sales[Order Date] ), SUMMARIZE ( CALCULATETABLE ( 'Sales', ALL ( Sales[Delivery Date] ), ALL ( 'Date'[Date] ), ALL ( 'Date'[Calendar Year] ) ), Sales[ProductKey] ), ALL ( Sales[Delivery Date] ), ALL ( 'Date'[Date] ), ALL ( 'Date'[Calendar Year] ) ) ), "distinct product sales", DISTINCTCOUNT ( Sales[ProductKey] ), "sales", COUNTROWS ( 'Sales' ) ) And got: Any help would be much appreciated. I wan to count the number of products in each year that were never sold before then, i.e. were sold in that year, for the first time ever. [1]: https://dax.do/fDTAmTl3kDIMaF/Solved1.8KViews0likes7CommentsHow to create index within a grouping in a matrix
Hi, I'm trying to create a measure that results in the Index column above. Assume that there is a matrix with a few layers in it, Region, SubRegion, Fiscal Year, and then Accounts. I would like the Index to start at the Fiscal Year Level. See above for reference. Repetition across the level below (Accounts) may or may not be needed. Thank you!466Views0likes1CommentCreating a dynamic summarization table based on measure values
Hello everybody! I have categorized my clients into 4 LRFM segments: Key, Frequent, Spender & Uncertain. Using measure. Client Status A Key B Uncertain C Uncertain D Frequent E Key F Key G Frequent H Key I Spender J Spender K Frequent L Uncertain I want a summarization table that shows something like this. Status # Clients Key 4 Uncertain 3 Frequent 3 Spender 2 Notice that my output in the first table is measure. But we can’t use measure as a legend. I don’t want to use columns because I want it to be dynamic and the summarization values change based on the slicers I have. What should I do? My lrfm measure: LRFM Analysis LRFM = IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="High","Key", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="High","Key", IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="Low","Key", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="Low","Key", IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="High","Spender", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="High","Spender", IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="Low","Spender", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="High" && [If Normalize R LRFM]="Low","Spender", IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="High","Frequent", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="High","Frequent", IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="Low","Frequent", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="High" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="Low","Frequent", IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="High","Uncertain", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="High","Uncertain", IF([If Normalize L LRFM]="High" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="Low","Uncertain", IF([If Normalize L LRFM]="Low" && [If Normalize F LRFM]="Low" && [If Normalize M LRFM]="Low" && [If Normalize R LRFM]="Low","Uncertain","Not Found"))))))))))))))))Solved910Views1like3CommentsSlicer doesn't work for table which is created in variable
Hi, I'm trying to create a new table for some specific date periods and percentage changes for some of them. I used calculated column for deposit and brought measures per row. It looks like as below, The issue is that, country- brand and brandsplit slicers don't affect the table. How can I adjust my table "_table1" as variable? The measure for yesterday, Thank you, VK642Views0likes4Comments