group by
42 TopicsGet an Latest date Records
Hi , i created below table by using 3 tables : dim TableA- state fact TableB- num (num of records), diff(measure) dim TableC- date_dt state num diff date_dt alabama 1000 100 20-Feb-25 alaska 2000 10 27-Feb-25 alaska 2200 200 27-Mar-25 arizona 1500 100 22-Feb-25 arizona 1000 -500 27-Mar-25 arizona 2000 1000 20-Apr-25 california 3000 100 22-Jan-25 california 4000 1000 22-Feb-25 california 1000 -3000 27-Mar-25 california 5000 4000 20-Apr-25 I need to generate the output shown below, where each state appears only once with its latest date without any repetition. Could you please guide me on how to create a measure or column in Power BI to achieve this result instead of the above output? required output: state num diff date_dt alabama 1000 100 20-Feb-25 alaska 2200 200 27-Mar-25 arizona 2000 1000 20-Apr-25 california 5000 4000 20-Apr-25 Thank you in advance. LakshmiSolved1.3KViews0likes5CommentsDAX: If () with Group_by on (id) and conditions on other columns
Hi, I have a table of the form: id case status 0 1 xx 0 555 yy 0 125 zz 2 87 yy 2 nn xx And I am trying to code something like the below: for every id if 1 case has status xx and 1 case has status yy, THEN I want yy = xx So the resulting table would be id case status 0 1 xx 0 555 **xx** 0 125 zz 2 87 **xx** 2 nn xx I tried with Column= IF ( MAXX ( FILTER ( 'Table', 'Table'[id] = EARLIER ( 'Table'[id] ) && 'Table'[status] = "xx" ), 'Table'[status] ) = "", "", "xx" ) but that doesn't work as it would transform all the *statuses* per *id* into -xx-. Any help on this? ThanksSolved524Views0likes1CommentDAX equivalent of GROUP BY and MIN - How do I count products launched, by year?
I want to create a measure that counts how many products were sold for the first time in a given year. That means if the product was sold in any year prior, it should not count in the current year. I would expect to do something like this: (code can be run and iterated here: [https://dax.do/fDTAmTl3kDIMaF/][1] ) DEFINE MEASURE 'Sales'[m1] = CALCULATE ( DISTINCTCOUNT (Sales[ProductKey]), SUMMARIZECOLUMNS ( Sales[ProductKey], CALCULATETABLE ( Sales, ALL( Sales[Order Date] ), ALL( 'Date'[Date] ), ALL( 'Date'[Calendar Year] ) ), "earliest_sale", MIN( Sales[Order Date] ) ), ALL( Sales[Order Date] ), ALL( 'Date'[Date] ) ) EVALUATE SUMMARIZECOLUMNS ( 'Date'[Calendar Year], "number of products sold for the first time", 'Sales'[m1] ) However, this returns the following: Which is exactly the same result as the one I get from EVALUATE SUMMARIZECOLUMNS ( 'Date'[Calendar Year], 'Sales', "distinct product sales", DISTINCTCOUNT ( Sales[ProductKey] ), "total sales", COUNTROWS ( 'Sales' ) ) Finally, going perhaps, a little bit crazy, I tried this: EVALUATE SUMMARIZECOLUMNS ( 'Date'[Calendar Year], FILTER( 'Sales', Sales[Order Date] = CALCULATE( MIN( Sales[Order Date] ), SUMMARIZE ( CALCULATETABLE ( 'Sales', ALL ( Sales[Delivery Date] ), ALL ( 'Date'[Date] ), ALL ( 'Date'[Calendar Year] ) ), Sales[ProductKey] ), ALL ( Sales[Delivery Date] ), ALL ( 'Date'[Date] ), ALL ( 'Date'[Calendar Year] ) ) ), "distinct product sales", DISTINCTCOUNT ( Sales[ProductKey] ), "sales", COUNTROWS ( 'Sales' ) ) And got: Any help would be much appreciated. I wan to count the number of products in each year that were never sold before then, i.e. were sold in that year, for the first time ever. [1]: https://dax.do/fDTAmTl3kDIMaF/Solved1.8KViews0likes7CommentsGroup By Calculated Column
How would I create the "Is Loyal v2" column in the Table View using DAX based on the first two columns? I want the outcome to equal "No" for all rows if there is a row that equals "No" for the ID in the first column. I know I can achieve this with Power Query, but wondering if it's possible in the table view. ID Is Loyal Is Loyal v2 1 Yes No 1 Yes No 1 Yes No 1 No No 1 Yes No 2 Yes No 2 No No 2 Yes No 2 Yes No 2 Yes No 3 Yes Yes 3 Yes Yes 3 Yes Yes 3 Yes Yes 3 Yes YesSolved2KViews0likes4CommentsGroup by one column and get average from another column
Hello all I have following table and I want to get with DAX avg for each character, so result should be this unfornatelly GROUP BY is not working as I expect..can anyone help me to understand where I am wrong? and what should be correct formula ?Solved844Views0likes3CommentsGoup by and count occurences meassure
Hi everybody. I'm new on the board. I have this Table (VendesAnnex), Order Num Line Num PX 1418 1 True 1418 2 True 1418 3 False 1419 1 True 1419 2 True 1420 1 False 1420 2 False 1421 1 True 1421 2 False 1422 1 False 1422 2 False 1422 3 False 1422 4 False And need a meassure that returns True/False after grouping (Vendes Annex) by [Order Num] where True means at least 1 [Line num] = "True" and False means that none [Line Num] ="True": Expected Resul would be: Order Num PX 1418 True 1419 True 1420 False 1421 True 1422 False If it is in two steps/Meassures is not a problem. I' ve tried different ways and the ouput I get is a filtered table where all values are "True". Thanks Folks!Solved1.9KViews0likes8CommentsDax to sum value grouped by two columns
Hi, I have the following stock table Date Material Batch Stockvalue 9/13/2023 A 2 100 9/12/2023 A 2 150 9/10/2023 B 1 75 9/9/2023 A 2 200 9/5/2023 A 1 5 A stock record will only be written if there is a transaction for that stock. I need to get the total value of the stock. Eg. if I check the stock value for 9/13/2023 for Material A the value should by 105 as Batch number 1 will have a value 5 and batch number 2 will have a value 100. How do I get this done using Dax. Thanks in advnce AmalSolved2KViews0likes8CommentsDAX table to create a revenue funnel visual?
Hi! my main fact table is financial transactions which look pretty much like this: date type amount 10/12/22 revenue 100$ 10/12/22 expense 50$ 01/01/23 revenue 100$ 01/01/23 expense 30$ 05/01/23 revenue 150$ 05/01/23 expense 75$ I want to create a revenue funnel visual that shows the conversion between the revenue and the margins. from what I understand, I need to get a table at this structure ( I can drop the year but I want to keep it for future visualization) year type amount 2022 revenue 100$ 2022 margins (100$-50$) = 50$ 2023 revenue (100$+150$) = 250$ 2023 margins (100$+150$) - (30$+75$) = 145$ Then I will drag the type to the funnel group and the amount to the funnel value. How can I create this table using DAX? Thanks! Tal549Views0likes1CommentCreating Separate Reports for each Group
Hello, I'm trying to create separate reports for each group (High School District). Specifically, each school district needs its own title "Quarterly Report", Payee & Payer Address, and the data table by school district. The closest I've gotten is to insert page breaks in the data table at the bottom of the report between each school district -- so in other words, I get one heading followed by page-broken tables by school district. Can someone point me in the right direction? Thank you!546Views0likes0CommentsDAX measure with left outer join, multiple to multiple
I have one table in data model with one row per employee, their current end previous manager, and their current and previous output: EmployeeID Current Manager Current Output Previous Manager Previous Output 1 A 10 B 5 2 A 20 A 15 3 B 30 A 40 4 B 5 B 10 In the reports view, I show the sum of current and previous output by current and previous manager respectively: Current Manager Current Output A 30 B 35 And: Previous Manager Previous Output A 55 B 15 I would like to left join the 'current output' table with the 'previous output' table on Current Manager = Previous Manager so I can calculate the output delta. What I want is this: Current Manager Current Output Previous Output Delta Output A 30 55 -25 B 35 15 20 I have tried writing a measure to give the answer, but can't figure out how to pass the values of the delta: Create Delta Table = VAR x2=GENERATEALL( SUMMARIZE('EmployeeTable', EmployeeTable'[Current Manager], "Sum Current Output", CALCULATE (SUM('EmployeeTable'[Current Output]))) ,SUMMARIZE('EmployeeTable', 'EmployeeTable'[het_name], "Sum Previous Output", CALCULATE (SUM('EmployeeTable'[Previous Output]))) ) RETURN x2Solved855Views0likes2Comments