"calculation group"
17 TopicsHow to lock TopN results in a matrix regardless of calculation group selection
Hi everyone, I have a matrix visual in Power BI with the following configuration: Rows: d_customer_ranking[ranking group] d_customer_ranking[ranking corporate group] d_customer_ranking[ranking name] Columns: d_Calendar[Month] Time Intelligence[TimeIntelligence] ← calculation group Values: TopN Customers_test Here’s my main measure: TopN Customers_test = IF ( ISINSCOPE ( d_Customer_Ranking[Ranking group] ), VAR NumOfCustomers = 'TopN'[TopN Value] VAR RankingGroup = SELECTEDVALUE ( d_Customer_Ranking[Ranking group] ) VAR TopCustomers_byCorporateGroup = TOPN ( NumOfCustomers, SUMMARIZE ( ALLSELECTED ( 'd_Customer_Ranking' ), 'd_Customer_Ranking'[Ranking Corporate Group], "CurrentBaseValue", CALCULATE ( TOTALYTD ( [Current (base)], d_Calendar[Date] ), REMOVEFILTERS ( 'Time Inteligence' ) ) ), [CurrentBaseValue] ) RETURN SWITCH ( RankingGroup, "Best Customers", CALCULATE ( [Current (base)], KEEPFILTERS ( TopCustomers_byCorporateGroup ) ), "Others", IF ( NOT ISINSCOPE ( d_Customer_Ranking[Ranking name] ), VAR TopAmount = CALCULATE ( [Current (base)], REMOVEFILTERS ( d_Customer_Ranking[Ranking group] ), TopCustomers_byCorporateGroup ) VAR AllAmount = CALCULATE ( [Current (base)], ALLSELECTED ( d_Customer_Ranking ) ) VAR OtherAmt = AllAmount - TopAmount RETURN OtherAmt ) ), [Current (base)] ) These are the Calculation Group measures: PY YTD CALCULATE( TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]), SAMEPERIODLASTYEAR(d_Calendar[Date]) ) Contribution PY YTD DIVIDE( CALCULATE( TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]), SAMEPERIODLASTYEAR(d_Calendar[Date]) ), CALCULATE( TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]), SAMEPERIODLASTYEAR(d_Calendar[Date]), ALL(d_Customer_Ranking) ) ) Actual YTD TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]) Contribution YTD DIVIDE( TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]), CALCULATE( TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]), ALL(d_Customer_Ranking) ) ) YoY Growth YTD VAR CurYTD = TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]) VAR PrevYTD = CALCULATE( TOTALYTD(SELECTEDMEASURE(), d_Calendar[Date]), SAMEPERIODLASTYEAR(d_Calendar[Date]) ) RETURN DIVIDE(CurYTD - PrevYTD, PrevYTD) The problem is that the Top 20 customers shown in the matrix vary depending on the calculation group selected (e.g., PY YTD, Actual YTD). As a result, the Top 20 for Actual YTD are not the same as the Top 20 for PY YTD. The order and the number of customers showing should remain consistent and based on the current year YTD value. In other words, I need a way to decouple the TopN definition from the calculation group context. Any suggestions on how to "freeze" the TopN list to the YTD ranking? Thanks in advance for any ideas!Solved1.2KViews0likes6CommentsRanking a parameter on filtered grouped table
Hi! I'm having trouble writing a measure that ranks a parameter. Essentially, the user inputs a numeric value as a parameter and my report should output it's ranking based on grouped sales by week and client. Filters can be applied. To make this exercise easier I have attached a picture of my report page and a sample PBI file. The column highlighted in red is the one NOT working properly. Would appreciate any tips on how to modify it. Since my parameter might not exist in my grouped table, I first created a measure that will return the closest value in order to then calculate the ranking. This works fine. Closest amount to parameter = var threshold = Parameter[Parameter Value] ---- returns parameter inputed by the user VAR SourceTable = ADDCOLUMNS ( ALLSELECTED ( Sales[Weeknum + ClientID]), "@Amt", [Sales] ) ----- temp table adding sales amount, grouped by weeknum and client var closest_above = MINX(FILTER(SourceTable, [@Amt]>= threshold), [@Amt]) var closest_below = MAXX(FILTER(SourceTable, [@Amt]<= threshold), [@Amt]) var result = if(abs(threshold-closest_above) < abs(threshold-closest_below), closest_above, closest_below) return result Second measure should return the rank of my parameter based on grouped table. Issue is that its not taking in account slicer filters applied to the report page. Essentially works fine until I select a filter in the slicer 'TransDesc'. Rank of parameter = var SourceTable = ADDCOLUMNS( ALLSELECTED ( Sales[Weeknum + ClientID]), "@Amt", [Sales]) var GroupedTable = ADDCOLUMNS(FILTER(SourceTable, [@Amt] <> BLANK()), "@Rank", RANKX(SourceTable, [Sales],,ASC)) var threshold = [Closest amount to parameter] var result = MINX(FILTER(GroupedTable, [@Amt]= threshold), [@Rank]) return result In example below, I would expect that Rank of parameter = 136 here is the link: RankingSample.pbix Any help is appreciated!Solved468Views0likes1Comment[Calculation Group] showing PY and CY in matrix when one option is selected on slicer
I have simple model fact and comparison (Dim). Due to performance issue fact was design with duplicated rows. each period has value for (1) CY and (2) PY. i created calucation group that is calculating value for CY and PY as: CY = CALCULATE( SELECTEDMEASURE(), REMOVEFILTERS(Comparison[ComparisonId]), Comparison[ComparisonId] = 1 ) It works but when i add it to matrix as below, when Comparison from dim is selected, then other value is hidden (in this case when CY is selected PY is hidden). Is there option to force CG to ignore comparison selection? So regardeles slicer selection always CY and PY will be visible? Switching of interaction is not an option due to page requirement and other measures presented in the matrix (CY, PY, delta, % change, calculation related to CY or PY based on selection) currently when slicer value is selected the other one goes blankSolved383Views0likes1CommentIn Search of an Efficient Approach for Grouping and Analyzing Measures
Hey everyone! I will now present the scenario I have, and I need your help to see how you would approach it. I have “solved” it in an incorrect way because my solution consumes too many resources and is inefficient I have 5 measures, measure1, measure2 … measure5. These measures visually need to be grouped (as a visual separation without totaling) into two groups: Group 1: measure1 …3 Group 2: measure4, measure5 For each measure, I have: Budget, Real, Budget LY, Real LY, Budget YTD, Real YTD, Budget LYTD, Real LYTD. I have 2 companies: Company 1, Company 2. The measures were developed before the existence of calculation groups (but I don’t know if the solution involves calculation groups). Now I will show you the grid structure I am looking to visualize. I need your help on how you would approach the problem. Thanks in advance.Solved577Views1like2CommentsGrouping Question
I'm trying to write a dax measure that will group Sales by Product. I can see via a table with Sales and Product columns what the result should be... Yet the following measure is off somehow... Gross Sales by Product = CALCULATE( SUM(financials[Gross Sales]), ALLEXCEPT(financials,financials[Product]) ) What am I doing wrong? EDIT: There was somehow a country filter applied to the first table, it's calculating the same as my dax measure now. So just to confirm that application of DAX code works to group by...?Solved1.9KViews0likes4CommentsCalculation group using filter modifier looks like a bug
Hi, guys, I have found a very strange calculation Percentage between the measure and Calculation Group. I expected to see the same calculations using filter modifiers in Calculation Group. I could not find any answer in your book about this feature in calculation group. Can you help me?Is it a Bug? And if I add the measure Sales% under the action of the calculation group, then the calculations become the same. How one measure can influence to another measure?It is magic. The dataset is here:https://fex.net/s/9rpnlb01.2KViews0likes4CommentsCalculation group that affects calculation item
Hello dear members I have created a calculation group that actually reference measures. So I have a calculation item for actual sales =[sales] A calculation item for PY sales =[PY sales] A calculation item for YOY% =[YOY], A calculation item for Target sales =[target] And calculation item for Target dif=[target dif] I have added all of them in to a matrix. Now I want to add a button and change between 2 different targets. Target 1 and target 2. I have created a separated table with target 1 and Target 2 and I have used an if statement to change the measure based on the selection. The target measure is something like that If( selectedvalue(target[target])="target 1", [target1], [target2]) It works fine but I was wondering if there is a more efficient way to resolve this and if it is possible to resolve it again by using calculation group. Thank you in advance 🙂608Views0likes3CommentsCalculate Sum of Expenses by Manager
Hi folks, I'm looking to calculate the sum of expenses (Ex. VAT Cost) by line managers as well as each individual travel type. I have two tables: The first "Expense" table contains the travel expense including and excluding travel costs by each colleague. The second is a "name" table containing the names of colleagues and line managers. I have constructed a hierarchy path and a corresponding matrix table showing how much each colleague has spent and the matrix is also showing how much money (Ex. VAT Cost) is spent by each manager. However, you can see that the matrix is also displaying the expenses of the employees. I have tried multiple ways, but I can't figure out how to only display the names of the managers alone. As you can see from the matrix, there are four managers -- "Samira Mishra, Darien Jacobse, Irene Monet and Hildr Tennyson." I tried filtering using the "Is Manager?" column, but the matrix shows the sum of expenses for only that manager, without including the expenses of their subordinates. If I separately calcualate the group expenses (Ex. VAT Cost) using a calculate and sum command (in a calculated column), I get the correct expenses by each manager, but incorrect when i filter by travel type. Matrix: Name Table: Colleague ID Colleague Name Line Manager ID Path Level1ID Level2ID Level3ID Level4ID Level1Name Level2Name Level3Name Level4Name Is Manager? 232072 Irene Monet 201854 201854|232072 201854 232072 Samira Mishra Irene Monet TRUE 264976 Timon Matthews 232072 201854|232072|264976 201854 232072 264976 Samira Mishra Irene Monet Timon Matthews FALSE A10637 Mohini Patel 232072 201854|232072|A10637 201854 232072 A10637 Samira Mishra Irene Monet Mohini Patel FALSE 299333 Vasia Bellincioni 3783 201854|281247|3783|299333 201854 281247 3783 299333 Samira Mishra Darien Jacobse Hildr Tennyson Vasia Bellincioni FALSE 295930 Amilcar Adam 3783 201854|281247|3783|295930 201854 281247 3783 295930 Samira Mishra Darien Jacobse Hildr Tennyson Amilcar Adam FALSE D18660 Dileep Ibrahimovic 281247 201854|281247|D18660 201854 281247 D18660 Samira Mishra Darien Jacobse Dileep Ibrahimovic FALSE 299391 Rosalee Jacques 281247 201854|281247|299391 201854 281247 299391 Samira Mishra Darien Jacobse Rosalee Jacques FALSE 3783 Hildr Tennyson 281247 201854|281247|3783 201854 281247 3783 Samira Mishra Darien Jacobse Hildr Tennyson TRUE 235419 Emanuel Hardwick 281247 201854|281247|235419 201854 281247 235419 Samira Mishra Darien Jacobse Emanuel Hardwick FALSE 7789 Emely Bentley 281247 201854|281247|7789 201854 281247 7789 Samira Mishra Darien Jacobse Emely Bentley FALSE 281247 Darien Jacobse 201854 201854|281247 201854 281247 Samira Mishra Darien Jacobse TRUE 289162 Chander Kaur 3783 201854|281247|3783|289162 201854 281247 3783 289162 Samira Mishra Darien Jacobse Hildr Tennyson Chander Kaur FALSE 201854 Samira Mishra 201854 201854 201854 Samira Mishra TRUE 241708 Dervla Jarrett 232072 201854|232072|241708 201854 232072 241708 Samira Mishra Irene Monet Dervla Jarrett FALSE Expense Table: (Partial) Name Table: Colleague ID Colleague Name Line Manager ID Path Level1ID Level2ID Level3ID Level4ID Level1Name Level2Name Level3Name Level4Name Is Manager? 232072 Kiran Sharma 201854 201854|232072 201854 232072 Xi Fung Kiran Sharma TRUE 264976 Blunt Smith 232072 201854|232072|264976 201854 232072 264976 Xi Fung Kiran Sharma Timon Matthews FALSE A10637 Mohini Patel 232072 201854|232072|A10637 201854 232072 A10637 Xi Fung Kiran Sharma Mohini Patel FALSE 299333 Suresh Kaladi 3783 201854|281247|3783|299333 201854 281247 3783 299333 Xi Fung Smith Wesson Hildr Tennyson Vasia Bellincioni FALSE 295930 Ameen Khan 3783 201854|281247|3783|295930 201854 281247 3783 295930 Xi Fung Smith Wesson Hildr Tennyson Amilcar Adam FALSE D18660 Clark Sasson 281247 201854|281247|D18660 201854 281247 D18660 Xi Fung Smith Wesson Dileep Ibrahimovic FALSE 299391 Rosafeld Jacqueline 281247 201854|281247|299391 201854 281247 299391 Xi Fung Smith Wesson Rosalee Jacques FALSE 3783 Blessen George 281247 201854|281247|3783 201854 281247 3783 Xi Fung Smith Wesson Hildr Tennyson TRUE 235419 June Sun 281247 201854|281247|235419 201854 281247 235419 Xi Fung Smith Wesson Emanuel Hardwick FALSE 7789 Bently Royce 281247 201854|281247|7789 201854 281247 7789 Xi Fung Smith Wesson Emely Bentley FALSE 281247 Smith Wesson 201854 201854|281247 201854 281247 Xi Fung Darien Jacobse TRUE 289162 Chand Persh 3783 201854|281247|3783|289162 201854 281247 3783 289162 Xi Fung Smith Wesson Hildr Tennyson Chander Kaur FALSE 201854 Xi Fung 201854 201854 201854 Xi Fung TRUE 241708 Ghulam Azad 232072 201854|232072|241708 201854 232072 241708 Samira Mishra Irene Monet Dervla Jarrett FALSE Expense Table: (Partial) First Name Middle Initial Last Name Inc. VAT Cost Ex. VAT Cost VAT Cost Full Name Type of Travel Smith M. Wesson £885 £738 147 Smith Wesson Flight Kiran K. Sharma £71 £59 12 Kiran Sharma Personal Car Blessen George £94 £78 16 Blessen George Business Car Blunt L. Smith £99 £83 16 Blunt Smith Business Car Jun Sun £70 £58 12 June Sun Personal Car Blessen George £598 £498 100 Blessen George Hotel Blessen George £40 £33 7 Blessen George Personal Car Xi Fung £614 £512 102 Samira Mishra Flight Clark D. Sasson £55 £46 9 Clark Sasson Personal Car Just to summarize again, I want to display the expenses by each manager, taking into account the expenses by their subordinates as well. Thanks for the help!Solved1.2KViews0likes4CommentsCalculate a date sequence on a row level per ID (in DAX)
Hi there, I have this data set where each patient goes through different treatments (each row is a new treatment). I would like to add a new column (using DAX) that creates a sequence of numbers from 1 to "N" for each Patient, being 1 assigned to the earliest date. This is what the new column should look like: Patient Created on (d/mm/yyyy) Treatment number (calculated column) Patient A 16/08/2023 3 Patient A 5/05/2023 2 Patient A 25/03/2023 1 Patient B 13/08/2023 2 Patient B 5/05/2023 1 Patient C 19/06/2023 1 Patient D 8/09/2023 2 Patient D 14/07/2023 1 Thanks!Solved634Views0likes2Comments