context
15 TopicsConvert 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.2KViews0likes8CommentsCalculate values in one fact table from another fact table
Hi , I have following data model which has 2 fact tables 3 dimension tables and 1 bridge table to resolve many to many relationship. I am trying to calculate Sales Volume since the contract Start Date for each "Product ID" in Contracts Table using following formula Sales Volume Since Contract Start Date= CALCULATE ([Total Volume], FILTER ( SalesFact, SalesFact[INVOICE_DATE] >= MIN ( Contracts[Contract Start Date] ) ), SalesFact[PRODUCT_ID] IN VALUES ( Contracts[Product ID] ), SalesFact[BILL_TO_CUST_ID] IN VALUES ( Contracts[Bill To ID] ) ) I get correct results when I throw this measure in a table which provides Context for MIN ( Contracts[Contract Start Date] ) . However, if I throw this measure in a card visual or in any other visual without a Contract Start date context I get incorrect results. Can somone please tell me how can I resolve this? I think I need to use somekind of iterator function to get the result I need, but I can't seem to figure it out. Thanks!2.6KViews0likes4CommentsCumulative Count with KPI
Hi, cumulative counts are covered extensively here but I can't see an answer to my specific problem. I'm trying to cumulatively count the number of calls a team of agents make in a day and benchmark them against a cumulative KPI. First I summarize the the number of agents per day based on the calls table. Active Agents = CALCULATE(COUNTROWS(SUMMARIZE(Calls,Calls[Date],Calls[AgentID])),FILTER(Calls,Calls[Role]="SalesAgent")) Then create the cumulative KPI for the calls up to yesterday and summed over "This Week" Calls KPI = CALCULATE([Active Agents]*60,ALL(Dates),Dates[This Week]="This Week",Dates[Date]<TODAY()) This works fine but when I do something similar for the number of calls they actually make during the week the KPI only shows me the previous day's total. Outbound Calls = CALCULATE(COUNTROWS(Calls),FILTER(Calls,Calls[Type]="O"),FILTER(ALLSELECTED(Dates),Dates[Date]<TODAY())) You can see in the images above when I inclide a date on the trend axis for the KPI the calls KPI is cumulative however the actual count of calls made is not. Removing the date gives the true cumulative figure for calls made but removes the trend axis. Can someone please help?2.3KViews0likes3CommentsReplay last non blank value
Hello, I've got a line chart with incremental hour in my axis, in my table there could be zero, one or more values for each hour. The basic function I'm starting from is calculate(average([value]), [item]="ItemINeed"), but I need my graph to substitute blank hours with the last single available value. For example I've got value 40 and 50 at 9AM, no values at 10AM, value 60 at 11AM: my graph should prompt 45 at 9AM, 50 at 10AM and 60 at 11AM. Is it possible in a dax measure? I think the problem is getting outside the time context of the line chart axis that acts like a filter on my measure also if I use variables. Thank you in advance!Solved1.3KViews0likes2CommentsCan'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.2KViews0likes3CommentsFilter and sclicer causing visualization discrepency
Hi I am a beginner in Power BI and I would like to know the feasibility/solution for my Queries. For a given data table "Prototype Modeling_freight" I have a measure as: volume = SUMX('Prototype Modeling_Freight', 'Prototype Modeling_Freight'[Sold Cases]) this converted to percentage for each type of equipment as: Volume distribution = DIVIDE([volume],CALCULATE([volume],ALL('Prototype Modeling_Freight'))),0) And visualized as clustered column chart Now there are specifically two things I want this chart to do: when I filter out through a date sclicer my chart must compare the data only within those sclicers, (note these sclicers can be other than dates) Eg: If you consider the Y axis in above picture, I want them to present 100%, or 'what was 25N's contribution in June month?'. Thank youSolved1.1KViews0likes4CommentsCalculating Average of Sum Measurement
I have created a measurement to calculate the difference between two value from separate table based on date and then take the average of those values, but I can't seem to get the correct average value. The initial part of the measurement works correctly by getting the difference for each month, but I can't figure out how to get the overall per account_id average once I take out the Date Values in the context?? As you can see in the total line and last snapshot the value is incorrect the total average should be -.46 for the Account_id.Solved999Views0likes1CommentUsing 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 _countSolved986Views0likes3CommentsIs 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!950Views0likes3Comments