"calculate"
58 TopicsErro em Calculate com múltiplas referências de filtros
Há alguma alteração documentada ou uma atualização no mecanismo de otimização do Power BI, a partir de março/26, que possa ter tornado mais rigorosa a validação de filtros com múltiplas referências à mesma tabela dentro de uma função CALCULATE? Tinha medidas antigas que estavam funcionando normalmente, apesar da semântica confusa, e passaram a retornar valores incorretos. Tive que reescrevê-las de uma forma mais explicita e semântica para voltarem a funcionar. Por exemplo: Haskell Medida Antiga = VAR QTDE = CALCULATE( Count(Tabela1[Coluna1]), Filter(Tabela2, [Coluna1] = 1), Tabela1, // ← TABELA INTEIRA COMO FILTRO Tabela1[Coluna2]="Sim", Filter(Tabela2, [Coluna2] = "1"), NOT(ISBLANK(Tabela1[Coluna3])) ) COALESCE(QTDE, 0) Refeita para: SQL Medida Nova = VAR QTDE = CALCULATE( COUNT(Tabela1[Coluna1]), Tabela1[Coluna2] = "Sim", NOT(ISBLANK(Tabela1[Coluna3])), Tabela2[Coluna1] = "1", Tabela2[Coluna2] = "1" ) RETURN COALESCE(QTDE, 0) Gostaria de entender o que mudou neste período para avaliar se precisarei revisar todas as medidas antigas em uso nos vários painéis que possuímos. Obrigado!Solved150Views0likes5CommentsStruggling to apply filters in my DAX
Hello, I'm really struggling on how to make my slicers work. So, I have an Employment table, with two date columns: Hire Dates and Termination Date. I have an active relationship with my Calendar[Date] and Employment[Hire Dates], and an inactive relationship with my Calendar[Date] and Employment[Hire Dates]. Below is my current DAX formula. My problem is, if I add the a Job Title or Location in my slicer or in my visuals, it doesn't work correctly. Both these columns can be found in my Employment table. Please let me know what I'm doing wrong. Thank you! Opening Headcount = VAR PeriodStartDate = MIN('Calendar'[Date]) // Gets Jan 1st of the selected period RETURN CALCULATE( COUNT(Employment[Employee #]), FILTER( ALL(Employment), // 1. Must be hired ON or BEFORE the start of the period Employment[Hire Date] <= PeriodStartDate && // 2. Must NOT be terminated BEFORE the start of the period // Logic: Either termination is blank OR it happens AFTER the start date ( ISBLANK(Employment[Termination Date]) || Employment[Termination Date] >= PeriodStartDate ) ) ) daxSolved575Views0likes2CommentsHelp with Full Quarter Total
So I'm trying to get a total for salesreps quotas for the current quarter, including dates that havent happened yet so I can create a daily quota requirement and then a QTD quota based on the daily quota for sales reps to see how they are pacing during the quarter. The formula I've been trying and playing around with is: CALCULATE([Sum of RSM Quotas], 'Quotas Unrelated'[Is this Qtr] = "TRUE") But it keeps giving me the full year total. Or this formula ends up giving me the month's total so I'm assuming its trying to do QTD with only one date. CALCULATE(SUM('Quotas RSM'[Quota]), 'Combined Table'[Current Quarter] = TRUE()) In my tables, I have the sales reps quotas for each month with 1 date attached. I also have a date table with a relationship to the quota table. Heres a super simplified example of my quota data. Quota Date Sales rep 52000 7/1/2025 rep 1 98000 7/1/2025 rep 2 33000 7/1/2025 rep 3 56000 8/1/2025 rep1 91000 8/1/2025 rep 2 34000 8/1/2025 rep 3 54000 9/1/2025 rep1 93000 9/1/2025 rep 2 32000 9/1/2025 rep 3Solved1.7KViews0likes7CommentsDAX help calculating Repeat Customers
Hi, I’m working in Power BI and trying to create a DAX formula to classify purchasers as either Repeat Customers or Single Customers based on their Customer ID and the dates they made purchases. For example: If a customer makes multiple purchases on the same date (e.g., 5/1/2025), they are considered a Single Customer. If they make purchases on multiple different dates (e.g., 5/1/2025 and 5/2/2025), they are classified as a Repeat Customer. If I were doing this in Excel, I would use a Pivot Table to distinct count the number of purchase dates per Customer ID, then use a COUNTIF to determine how many customers have only one purchase date (Single Customer) versus more than one (Repeat Customer). This is what I’m trying to replicate using DAX in Power BI. These are the DAX formulas I've tried: Single_Customers = COUNTROWS(filter(DISTINCT('Sales'[Customer ID]),CALCULATE(COUNT('Sales'[Sales Date]))=1)) Repeat_Customers = COUNTROWS(filter(DISTINCT('Sales'[Customer ID]),CALCULATE(COUNT('Sales'[Sales Date]))>1)) Single_Customers = COUNTROWS( FILTER( VALUES('Sales'[Customer ID]), CALCULATE(DISTINCTCOUNT('Sales'[Sales Date])) = 1 ) ) Repeat_Customers = COUNTROWS( FILTER( VALUES('Sales'[Customer ID]), CALCULATE(DISTINCTCOUNT('Sales'[Sales Date])) > 1 ) ) Here is some sample data. If I did this in excel with a pivot table and distinct count it, I'd have 5 Single Customers and 1 Repeat Customer. Customer ID Sales Date 3808 2/11/2025 1833 5/16/2025 3808 2/11/2025 2879 2/11/2025 1727 5/16/2025 1727 4/18/2025 2036 2/11/2025 1128 4/18/2025Solved3.5KViews0likes7CommentsHelp Adding Calculate Conditions to Switch Function
Need help adding correct calculations into my Switch function using two tables: 1) PPI (premium per phone interaction) table 2) PROD sales table Calculate "Total PPI" using this formula: Total Premium (from PROD Sales)/Total Count of PPI (from PPI) There is active relationship between "Date" and inactive between "Advisor" (not sure if I set it up correctly) I've included my PBI project with sample data and visuals to download/view: Power BI PPI Project Below my existing Switch statement; however I'm not getting correct results: Total PPI = SWITCH( TRUE(), //Case 1: When Advisor and Date selected HASONEFILTER('PROD SALES'[Advisor]) && HASONEFILTER('PROD SALES'[Date]), CALCULATE( DIVIDE([TotalPremium], [PPI Calls])), ), //Case 2: Only date selected HASONEVALUE('PROD SALES'[Date]), CALCULATE( DIVIDE ([TotalPremium],[PPI Calls]), USERELATIONSHIP('PROD SALES'[Date], 'PPI'[Date]) ), //Case 3: Only Advisor is selected HASONEVALUE('PROD SALES'[ADVISOR]), CALCULATE( DIVIDE ([TotalPremium],[PPI Calls]), USERELATIONSHIP('PROD SALES'[Advisor], 'PPI'[ADVISOR]) ), // Default: average over all call times if no or multiple selections DIVIDE([TotalPremium],[PPI Calls]) ) I need to add the following conditions to calculate PPI as well: - Selecting Department Only - Date + Department - Advisor + Date + Department My priority is when selecting a single date to show the correct PPI result. Total Premium selecting the date 5/15: $84,179.52 # PPI Calls from PPI Table for the selected date 5/15 = 142 Total Premium / PPI count = Total PPI Expected Total PPI result: $592.81 TOTAL PREMIUM FOR "Field" Department (from Prod Sales table): $846,573. 08 PPI Count FOR "Field" Department (from PPI table): 1,202 Total Premium / PPI count = Total PPI Expected Total PPI result when "Field" is selected: $704.30 Total Premium for "Call Center" Department (from Prod Sales table): $951,098.02 PPI Count for "Call Center" Department (from PPI table): 1,702 Total Premium/ PPI Count = Total PPI Expected Total PPI result when "Call Center" is selected: $558.81 Expected PPI when no filter is applied: $619.03 Appreciate your help!Solved721Views0likes2CommentsRanking with RANKX, FILTER, ALL & CALCULATE not working in Direct Query mode
Has anyone had issues ranking using Direct Query vs import modes? I am using the following measure which works when the table is imported but not in direct query mode: Rank Test = RANKX( FILTER( ALL( accounts[last_program_size], accounts[program_size] ), accounts[last_program_size] = MAX(accounts[last_program_size]) ), CALCULATE( sum(accounts[count_flag]) ) ) A number of the functions used have this remark in the official documentation but I am not using it in a calculated column and do not have RLS configured. This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules. Thanks.Solved2.4KViews0likes11CommentsVariance between Two Years on same Date Axis using same Amount Column
Unfiltered: Filtered: The task at hand is simple, take the 2025 values (Food Revenue, Beverage Revenue, etc.) and subtract the 2024 values from the correlated field (first screenshot). However, I am running into issues with the date axis it lies on and how to correctly display only the months needed. The formula used takes the sum of the current year (CY, Dec 2024 - Mar 2025) for a specific account, and subtracts it from the balance of the prior year (LY, Dec 2023 - Mar 2024). This does in fact work, as the values shown in the second screenshot are correct for Food Revenue Variance for the months needed thus far (fiscal year starts in December, so December 2024 - March 2025). However, when I filter to just show the months needed, the values revert to only show the balances correlated with the current year (CY). Any ideas on how to show this variance correctly? In layman's terms, basically need to INCLUDE data from all months relevant (Dec 2023 - Mar 2024, Dec 2024 - Mar 2025), but I only need to DISPLAY the months with the correct values for variance (Dec 2024 - Mar 2025). DAX measure: VARI Food Revenue = VAR CY = CALCULATE(SUM(ConsolidatedReport[Amount]), ConsolidatedReport[GLAccount] = "450000", DateDim[CurrentFiscalYear] = 0) VAR LY = CALCULATE(SUM(ConsolidatedReport[Amount]), ConsolidatedReport[GLAccount] = "450000", DateDim[CurrentFiscalYear] = -1, REMOVEFILTERS(DateDim[Date].[Year])) RETURN CY - LYSolved868Views0likes4CommentsNumber of type a and b stores opening by month
So This problem is in 2 parts Firstly I want to calculate accumulative totals of store a and b types opening by end of september, october, nov and so on one column store type with vaules a,b, c and d another column dates secondly i have measure which have counted total number of stores (TOTAL_NO_STORES) and another which as counted number os stores c and d (C&D) which have already opened therefore i want to plot number of store a and b's each month add them to the the total already opened stores and divide this by total number of stores so it should go up septemner 80%, october 83% and so on. Any help greatly appreciatedSolved725Views0likes2CommentsCalculation Headeach
I Have this type of data And I want to run a repport like this The first repport work fine, but when i collapse the society, the cumulative to do is not the cumulative I want (The cumulative for all the society regardless the month). If you have ideas please don't hesitate to give me your feedback. Kind regards1.9KViews0likes4CommentsDivide measure that excludes values without Calculate
Hi I wish to amend the following query to exlcude "No" from the numerator as well as the demoninator. However if I use CALCULATE to try and achieve this it loses the context and sets all values to 1 (or 100%) within my matrix. How do I exclude "No" from the numerator? % of Responses = IF( ISINSCOPE(Survey[Responses]), DIVIDE( COUNTA(Survey[Responses]), CALCULATE( COUNTA(Survey[Responses]), Survey[Responses] <> "No", REMOVEFILTERS(Survey[Responses]) ) ) )Solved1KViews0likes4Comments