"dax "
159 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!Solved150Views0likes5CommentsMultiple DAX for WoW, YoY, MoM Advice
I'm trying to find the best way to build a KPI overview for a commodity. I have 3 grades of this commodity with new weekly prices. For each need to be able to show: - Week over week price change - Month over month price change - Year over year price change I finished building the week over week and I have 9 DAX measures: - Current Week price - Last week price - Price change % My list is growing as I get into Month over Month..... Is this really the best method???Solved1.2KViews0likes4CommentsDynamically show dimension values from the latest transaction in a group
I have a transaction table of Container movements (to customer and back to warehouse). How to make data architecture to get requirements?: To show in a table visualization latest records (dimension values) of each Container_Id by MovementDateTime? I made a Metric with a sign 1, if it is a latest record and a solution worked well, when a Container_Id was filtered, but got an error of calculation limit, when I wanted to show all Container_Id. Any suggestions? How to filter dynamically (using Date filter) latest movement records of each Container_Id?Solved805Views0likes5CommentsHow to write this IF statement for same date, but different statuses?
Hello, I have the two columns below in the same table. "Cookie Type" is text field and "Baked_Date" is a date value. How can I write the IF statement in DAX for the concept: If the same baked_date for Cookie_type "Chewy" and "Chunky", then "Eat", otherwise "do not eat". I added the "Grape" value to show that there are other values in the dataset that are not relevant. Cookie Type Baked_Date Chewy 03/27 Grape 03/27 Chunky 03/27 Thank you!Solved994Views0likes6CommentsMatrix subtotal showing incorrect totals when using TREATAS() to map Allocation Units per employee
Hi, I am working on a Power BI matrix visual where I need to display Allocation Units per employee and also show correct subtotals at the department level and grand total level. Matrix Structure Rows: DepartmentName EmployeeName Values: Allocation Units (measure) Tables Used Table 1: Activity_Log_Table Contains: DepartmentName EmployeeName Table 2: Resource_Allocation_Table Contains: StaffFullName AllocationUnits There is no direct relationship between these tables, so I am using TREATAS() to map EmployeeName with StaffFullName. Current Measure Allocation Units Measure = CALCULATE( MAX('Resource_Allocation_Table'[AllocationUnits]), TREATAS( VALUES('Activity_Log_Table'[EmployeeName]), 'Resource_Allocation_Table'[StaffFullName] ) ) Problem The measure returns correct values at the EmployeeName level, but: DepartmentName subtotal is incorrect Grand total is incorrect Power BI recalculates totals instead of summing visible rows Expected Behaviour I want the matrix totals to behave like Excel-style aggregation: Show correct allocation units per EmployeeName Show subtotal per DepartmentName as sum of EmployeeName values Show correct grand total as sum of all EmployeeName values Avoid duplicate counting when EmployeeName appears multiple times Sample Data Activity_Log_Table DepartmentName EmployeeName Orion Alex M Orion Nina P Orion Kevin L Nova Daniel R Nova Sophia T Resource_Allocation_Table: StaffFullName AllocationUnits Alex M 40 Nina P 25 Kevin L 15 Daniel R 35 Sophia T 20 Expected Matrix Output DepartmentName EmployeeName Allocation Units Orion Alex M 40 Orion Nina P 25 Orion Kevin L 15 Orion Total 80 Nova Daniel R 35 Nova Sophia T 20 Nova Total 55 Grand Total 135 Currently, subtotals and grand totals are not matching the expected summed values. What is the correct DAX approach to ensure totals aggregate properly when using TREATAS() inside a matrix visual? Thanks, SBCSolved712Views0likes3CommentsCombining three CONCATENATEX Measures with results from two Tables
Hello, I am trying to create a status report that pulls in text updates from two tables (two sharepoint lists). Each Table is realted in a Many to 1 with an Intake Table that contains my projects. Working seperatley I've created three Dax Measures that uses CONCATENATEX to return a bulleted list of updates that meet certain criteria. Because of this, each Measure has a Filter with conditions to the table I am pulling data from. Each Measures works alone, however, when I attempt to combines these measures I find that I am only able to apply context to one table. For example, if I use an ALL statment in a nested calcuation this will clear results from the first measure and if I do not clear results the second measure will not return results. To me, this means the CONCATENATEX is running into a null or blank value which means the one of the Filters is not providing a needed context. For refrence this is my combined measure that will only return results for the second part: Measures use three tables. PMO Project Intake has a one to many realtionship with PMO Status Updates and PMO RAID LOG. PMO RAID Log and PMO Status Updates are not related (would need to be many to many and not sure it would help?) Next these are the two measures that work correctly when added seperatly: CARBULLTEDRAID = "Issues & Decision Points:"& UNICHAR(10) &CALCULATE(CONCATENATEX( FILTER('PMO RAID Log', 'PMO RAID Log'[Risk Type]<>"Risk" && 'PMO RAID Log'[Status]= "Open"&& 'PMO RAID Log'[FieldValuesAsText.ProjectName]=SELECTEDVALUE('PMO Project Intake'[Project Name])), UNICHAR(8226) & " " &('PMO RAID Log'[Description])&"-"&('PMO RAID Log'[Resolution])& UNICHAR(10)& UNICHAR(10) ,) ) CARBULLTEDLIST = "STATUS:"& UNICHAR(10) &CALCULATE(CONCATENATEX( FILTER('PMO Status Updates', 'PMO Status Updates'[CommentType]<>"Next Steps" && 'PMO Status Updates'[IncludeinCurrentReporting?]= True&& 'PMO Status Updates'[FieldValuesAsText.ProjectName]=SELECTEDVALUE('PMO Project Intake'[Project Name])), UNICHAR(8226) & " " &('PMO Status Updates'[Created])&"-"&('PMO Status Updates'[CommentType])&"-"& 'PMO Status Updates'[FieldValuesAsText.StatusText], UNICHAR(10)& UNICHAR(10) ,'PMO Status Updates'[Created],DESC) ) This is the combined value which is not working: Combined Measure = VAR Part1 = [CARBULLTEDRAID] VAR Part2 = CALCULATE( [CARBULLTEDLIST], ALL('PMO Status Updates') ) RETURN Part2 & " | " & Part1 The above only returns the results for measure [CARBUILTED RAID] and not the others: I underestand I could create a new table with all of these statues together in M, however, I am wondering if I am missing something the CONCATENATEX Statment. Is is possible to combine the results of multiple measures that use CONCATENATEX and keep the context for each measure? And if so how can I nest the DAX that restest context without having the rest apply where it isn't allowed? Thank you!Solved2.6KViews0likes14CommentsCalculating Cumulative Inventory with a Conditional "Reset to Zero" if Previous Month is Negative
I am building an Inventory Projection report in Power BI. I need to calculate the Opening Inventory for each month based on a starting balance from February 2026, then adding/subtracting monthly movements (Purchase Orders vs. Forecasts). The core challenge is the reset logic required for planning: Standard Accumulation: If the balance is positive, it should carry over to the next month as the Opening Inventory. Conditional Reset: If the calculated balance for a month is negative (e.g., April ends at -51), I still want to show that negative value for that specific month. The "Planning Start" Rule: However, for the next month's calculation (e.g., May), the calculation should not start from -51. Instead, it should reset to 0 and then apply that month's movements (PO - Forecast). Current Conflict: A standard cumulative DAX measure carries the negative debt forward (e.g., $-51 + (-346) = -397$), which is logically correct for accounting but incorrect for my supply planning needs. Attempts to use MAX(0, ...) often hide the negative values I need to see in the current month or cause "Circular Dependency" errors when trying to reference the measure's own previous value. Data Structure: DateTable: Standard calendar table. Opening Balance: A static value from a history table for the starting month (Feb 2026). Measures: [IN_PO], [Received Qty PO], and [Item Forecast]. Example of Desired Output: Month Calculation Logic Opening Inventory (Result) Feb Starting Balance 428 Mar $428 + 268 - 405$ 86 Apr $86 + 0 - 346$ -51 (Show negative) May Reset to 0 because April was negative -261 (0 + May movements) Question: How can I write a DAX measure that iterates through the months and resets the "Internal Carryover" to zero without losing the visibility of the negative result in the previous month's row?Solved773Views0likes3CommentsDAX standalone query execution using python
Hi, iwanted to execute DAX query through service principal in python standalone (vsCOde). but i got the error as below. Status Code: 401 {"error":{"code":"PowerBINotAuthorizedException","pbi.error":{"code":"PowerBINotAuthorizedException","parameters":{},"details":[],"exceptionCulprit":1}}}Solved1.3KViews0likes5CommentsDAX Query - Blank Result from Query when both parameters have multiple values
When I run my paginated report and provide the parameters I get the following error: The 'HiddenInsurerParam' parameter is missing a value. Below is my code, the idea is to create a distinct list of insurers from two different tables 'CAClaims' and 'Corsair Policy Years'. The @insurer and @insuredName parameters filter the 'CAClaims' table and @CorsairInsuredName filters 'Corsair Policy Years'. I then want a distinct list of the insurers from each, so I'm taking the union over the two filtered tables. When I only provide one value for either @insuredName or @CorsairInsuredName it works fine, however when I put two values into each I get the missing value error and I can't figure out why. CoPilot expected it was an issue with pathitem, but it wasn't able to assist in providing a workaround. The parameters will be a list of strings selected by the user from a list coming from the database. DEFINE // --- Normalise parameter delimiters: replace "," with "|" --- VAR _Insurer = SUBSTITUTE(@Insurer, ",", "|") VAR _InsuredName = SUBSTITUTE(@insuredName, ",", "|") VAR _CorsairInsuredName = SUBSTITUTE(@CorsairInsuredName, ",", "|") // --- Split parameters into tables using PATHITEM on cleaned strings --- VAR InsurerList = SELECTCOLUMNS ( ADDCOLUMNS ( GENERATESERIES(1, PATHLENGTH(_Insurer), 1), "InsList", PATHITEM(_Insurer, [Value]) ), "Insurer", [InsList] ) VAR InsuredNameList = SELECTCOLUMNS ( ADDCOLUMNS ( GENERATESERIES(1, PATHLENGTH(_InsuredName), 1), "InsName", PATHITEM(_InsuredName, [Value]) ), "InsuredName", [InsName] ) VAR CorsairInsuredNameList = SELECTCOLUMNS ( ADDCOLUMNS ( GENERATESERIES(1, PATHLENGTH(_CorsairInsuredName), 1), "CorsInsName", PATHITEM(_CorsairInsuredName, [Value]) ), "CorsairInsuredName", [CorsInsName] ) // --- Flags: only apply a filter if the parameter list is non-empty --- VAR HasInsurerFilter = COUNTROWS(InsurerList) > 0 VAR HasInsuredFilter = COUNTROWS(InsuredNameList) > 0 VAR HasCorsairInsuredFilter = COUNTROWS(CorsairInsuredNameList) > 0 // --- Apply parameter-aware filters to each source table --- VAR CAClaimsFiltered = FILTER ( 'CAClaims', // Insurer filter (on CAClaims) if provided (NOT HasInsurerFilter || SUMX ( InsurerList, INT( CONTAINSSTRING( 'CAClaims'[Insurers], [Insurer] ) ) ) > 0 ) && // Insured name filter (on CAClaims) if provided (NOT HasInsuredFilter || SUMX ( InsuredNameList, INT( CONTAINSSTRING( 'CAClaims'[Insured Name Simplification], [InsuredName] ) ) ) > 0 ) ) VAR CorsairFiltered = FILTER ( 'Corsair Policy Years', // Assured filter (on Corsair) if provided (NOT HasCorsairInsuredFilter || SUMX ( CorsairInsuredNameList, INT( CONTAINSSTRING( 'Corsair Policy Years'[Assured], [CorsairInsuredName] ) ) ) > 0 ) ) // --- Build the distinct union of insurers --- VAR AllInsurers = DISTINCT ( UNION ( SELECTCOLUMNS(CAClaimsFiltered, "Insurers", 'CAClaims'[Insurers]), SELECTCOLUMNS(CorsairFiltered, "Insurers", 'Corsair Policy Years'[Insurers]) ) ) EVALUATE AllInsurers ORDER BY [Insurers]Solved510Views0likes1CommentDAX logic needed to determine order lines value of new, existing or shipped orders
Hello! I am trying to come up with the DAX logic to determine order lines value of new, existing or shipped orders. New order value needs to show a sum of USD of new order lines in the most recent week (orders not present in previous week). Existing order value needs to show a sum of USD of order lines that exist in both current and previous weeks (summing only values in current week to avoid duplication). Shipped value is sum of orders that exist in previous week, but not current week. I can’t split table into weeks, no new tables in DAX based on my fact table. I must only operate in DAX, no MS Query solutions. I am not restricted on the number of columns or measures I can create with DAX. I have ‘Calendar’ table in addition to my fact ‘Orders’ table. Here is sample of fact ‘Orders’ table:Solved646Views1like4Comments