context
15 TopicsMeasure referencing other measures returns different result than when referencing local variables
The following DAX returns the correct values for result1 in all contexts, including the total. For result2, the results are correct in the row context; for example if I create a visual with rows by 'Item'[Label]. However, the total amount does not match result1. result1 references other measures with the same exact definition as their VAR counterparts here. result2 uses the VARs defined here. I obvisously am missing something with context, or perhaps need some CALCULATE? However, I've tried adding CALCULATE to various places here, as well as in the standalone measures and it did not help. How do I get result2 to produce the same number as result1 in all contexts? Consolidated 9L ANA-1542(Consolidated) = VAR Consensus = SUMX ( FILTER( '_Item Budgets', RELATED('Item Budget Name'[Item Budget Status])="Under Development" ), '_Item Budgets'[Quantity 9L] ) VAR WSfinance = SUMX ( FILTER( '_Item Budgets', RELATED('Item Budget Name'[Item Budget Status])="Released" && RELATED('Nav Department'[Dept Code])="20" ), '_Item Budgets'[Quantity 9L] ) VAR DTCfinance = SUMX ( FILTER( '_Item Budgets', RELATED('Item Budget Name'[Item Budget Status])="Released" && RELATED('Nav Department'[Dept Code]) IN { "35", "40", "45", "50" } ), '_Item Budgets'[Quantity 9L] ) VAR result1 = SUMX( SUMMARIZE( '_Item Budgets', 'Item'[Label], "xxx", IF( ISBLANK([Consensus]), [WSfinance], [Consensus] ) + [DTCfinance] ),[xxx] ) VAR result2 = SUMX( SUMMARIZE( '_Item Budgets', 'Item'[Label], "xxx", IF( ISBLANK(Consensus), WSfinance, Consensus ) + DTCfinance ), [xxx] ) RETURN CONCATENATE(format(round(result1,2),"Standard"), CONCATENATE(" | ", format(round(result2,2),"Standard")))Solved663Views0likes3CommentsIs possible to ignore row filter context in a table ?
Hi! I have found various similar issues to this one in the forum but no one of solutions provided works for me 😞 I need for some calculations in a table, the value of the selected value in Group filter. It works OK in a card (as displayed in screenshot attached) , but, when I tried to use it in a table, it change between 2 and 3 (you can see in the table in the screenshot), I understand this is due to the row context filter is being applied to the measure. I need that the value "Selected Group" in my table remains being 3 (the one selected) not depending on row context filter, hoy can I reach that ? I tried with ALL, ALLSELECTED combinations with no success at all Currently my "Selected Group" Measure looks like: Selected Group = VAR currGroup = MAX('Table'[Group Code]) RETURN CALCULATE( MAX('Table'[Group Code]), FILTER ( ALLSELECTED('Table'), 'Table'[Group Code] = currGroup ) ) Thansk in advance!958Views0likes3CommentsCan't solve context transition in DAX
Hello, First, I would like to thank you for taking the time to read me and to help me, i'm strugggling with this issue. I'm migrating a report from Tableau to PowerBI for my work and I have somes discrepancies between both. In fact, I obtain the same values when the calculations are in a row level but it's not the case anymore when it's on an aggregated level (matrix table). It's the case for differents values but I suspect a specific measure at the root of others calculations. Looking on internet, it seems related to the context transition in DAX. I tried a lot of different things to fix this but nothing worked. So i'm afraid to not have enough knowledge in dax to solve it. That's why i'm asking your help. First thing to know is that the data model is pretty easy, it's a single table containing few columns we need to make calculations. Those calculations are nested so I have to talk about different measures to know which one is linked to the context transition issue. I will take the easiest as example : I have to count serial numbers accross different dimensions ; the first is just a distinctcount and the second a distinctcount with condition. 1) Serial Number Distinctcount = DISTINCTCOUNT('table'[SERIAL_NUMBER]) 2) Complete Serial Numbers = IF(measure1 + measure2 + measure3 > 0, [Serial Number Distinctcount]) At a row level, it distinguishes all the serial number and the complete one. However, it's not the case at an aggregated level (in matrix table) where both measures returned identical values. It's the same for others calculations so I suspect one variable among the condition (MEASURE3) because it is used in each wrong calculation. The MEASURE3 measure is pretty big but basically wants to get the average of a measure for a specific scope/dimensions. The scope formula (removefilters/summarize) should replace the "Fixed" LOD in tableau. There is different level of granularity depending if the previous one is blank or not, I will only show the first one to be brief. MEASURE3 = VAR granularity1= CALCULATE( AVERAGEX('table', [Spend measure]) , REMOVEFILTERS('table'), SUMMARIZE('table', [COLUMN1], [COLUMN2], [COLUMN3]) ) VAR granularity2/3/4/5 = same pattern with different columns in the summarize function. RETURN SWITCH( TRUE(), NOT(ISBLANK(granularity1)), granularity1 ,NOT(ISBLANK(granularity2)), granularity2 ,NOT(ISBLANK(granularity3)), granularity3 ,NOT(ISBLANK(granularity4)), granularity4 , granularity5 ) This measure3 is used in different calculations so I think that it's this one that causes the issue. There is also a measure at the root of this one (spend measure) and so on, so it's maybe "deeper" but I will stop there to not overload you. I will add the details if needed but in sum, the measures are mainly based on an iterator function to retrieve something and apply more calculations or filters. I read about context transition so I tried to use CALCULATE() before the iterators and/or use measures in the calculation but nothing worked. Hoping you could help me ! Many thanks in advance,Solved1.2KViews0likes3CommentsConfusion with Filter / Context
Hi I am confused with some results using an explicit filter rather than an implicit filter. I have one fact table (ASB cases) and a Date table. The two tables have an active relationship between Calendar[Date] and ASB[Reported date]. I need a measure based on a Call Due date, where the call is made on time so am using USERELATIONSHIP. I have got the measure working based on the following. Initial Response on Time = CALCULATE(COUNTROWS('ASB Case'), USERELATIONSHIP('ASB Case'[Call Due to Reporting Party], 'Calendar'[Date]), 'ASB Case'[Contacted Reporting Party On Time?] = "On-Time" ) My initial Dax which returned incorrect results was Broken Initial Response on Time = CALCULATE(COUNTROWS('ASB Case'), USERELATIONSHIP('ASB Case'[Call Due to Reporting Party], 'Calendar'[Date]), FILTER('ASB Case','ASB Case'[Contacted Reporting Party On Time?] = "On-Time")) Clearly the way the filter is being used is wrong, but I can't really see the difference. I know Filter removes existing related filters first - so if anything was to happen I would have expected to see even more cases? If anyone can help I'd be really grateful. I'd also welcome any advice on steps I could take to debug the issue. Many thanks in advanveSolved694Views0likes1CommentWrong Column Totals (Matrix)
I wrote a DAX measure that convert a YTD balance to a common currency (EUR). The measure works well when a single company is selected (1 currency) but generates a wrong Total column when I try to select 2 or more companies (currencies). Act_Eur_Ytd = VAR NUMERATOR = [Act_Lc_Ytd] VAR DENUMERATOR = CALCULATE(AVERAGE('Facts'[Avg_Ytd_Fx_Rate]), ENDOFMONTH('Calendar_Table'[Date].[Date])) RETURN ROUND(DIVIDE(NUMERATOR,DENUMERATOR),2) Example: The expected output of the matrix is: The current behavior of measure Act_Eur_Ytd is: When Company 1 alone is selected, Numerator properly sums EUR amounts and divides them by 1 When Company 2 alone is selected, Numerator properly sums CNY amounts and divides them by 0.1 When both companies are selected, Numerator sums EUR + CNY (wrong) and divides by an average (wrong). The exchange rate is linked to calendar, in order to convert at the latest average rate of the selected Month/Year. In order to give a better context, I attach the real life example, with source data. DOWNLOAD: Example (pbix) and Source Data (xlsx) I appreciate the help of the community to properly correct the syntax of my DAX measure. Thank you. MarcoSolved887Views0likes2CommentsUsing VALUES + ALL instead of just ALL. Resolution included - Need to know WHY it works
Hi there, I recently ran into the following issue. My team has since resolved it (included) but we don't know 'why' it is the resolution. The ask: Calculate a Distinct Count of Values where the Primary Key IN a list of PK's defined by a subquery. The strange thing is, that when we ran the subquery through DAX Studio by itself, it returned the expected results. Thank you for taking a look! The DAX that WORKED: VAR _subq = CALCULATETABLE ( VALUES( table[field] ), ALL( table ), table[field2] = "Yes" ) VAR _count = CALCULATE ( DISTINCTCOUNT( table[field] ), table[field] IN _subq) RETURN _count The DAX that DID NOT WORK: VAR _subq = CALCULATETABLE ( ALL( table[field] ), table[field2] = "Yes" ) VAR _count = CALCULATE ( DISTINCTCOUNT( table[field] ), table[field] IN _subq) RETURN _countSolved988Views0likes3Commentsunpivot the data and consider the context
Hi, I want to create a combo visual and so the data needed is one common axis column and two values, I could't find a way to create visual with the original data, the data seems need to be unpivoted and there are many others fiters to be considered, like location and other columns not listed. I am new user of DAX and ask for help, could this problem can be solved use DAX? Thank you.Solved897Views0likes3CommentsConvert SAP BO measure with Foreach() operator to DAX formula
Hi I'm pretty new to SAP BO and I'm trying to convert a measure that I've found in a report to DAX language. The foruma uses the context operator FOREACH() on two columns ([Data].[KPI Group] and Data].[KPI Name] ) and I don't know how to write it in DAX. Could you please help me figuring out? Here's the code: SUM( IF( [Not Available] FOREACH( [Data].[KPI Group];[Data].[KPI Name] )="Y" ) THEN 1 ELSE 0 ) Thanks3.2KViews0likes8CommentsFilter on multiple measures for specific context
Greetings. I have a financial report that has an undeseriable output based on row context. For whatever reason accounting will post a expense transaction and then reverse so the total amount will be zero. It shows up in the report as shown below (Total Actual) since there are data values. I can't just filter out Total Actual <> 0 since there are times where there are budget transactions, but no expenses. I can't filter out Total Variance <> 0 since sometimes total budget magically equals total expenses. I need a measurement where it would filter out rows produced under a context where Total Budget = 0 and Total Actual = 0. I'm having issues producing a compund measurement that I could apply to the matrix visual to capture and filter out this scenario.Solved846Views0likes2Comments