earlier
27 TopicsFlag to mark two lowest values from Table. Grouped by other columns
Hello, I am using table in direct query mode as source. Table shows active users already grouped per Month, country, User_Tier, User_Group for last 12 weeks. Example below. Example table is smaller, but by default each month based on Month_Key has 12 Reported_weeks. Combinations of possible User_Tier, User_Group differs - so it may be 1 row per Reported_week or 5 tows per reported_week. Country Month_Key Reported_Week USER_TIER User_Group Weekly_Users_Count PT 20240901 202428 A H 20 PT 20240901 202428 B J 10 PT 20240901 202429 A H 30 PT 20240901 202429 C H 20 PT 20240901 202430 B J 10 PT 20240901 202430 C H 30 FR 20240901 202428 B G 50 FR 20240901 202428 B T 40 FR 20240901 202429 A G 100 FR 20240901 202429 A G 55 FR 20240901 202430 A G 66 Currently there is a measure that caluclates a Weekly number of active users by: # Weekly Active Users = Calculate(Divide(Sum(Table[Weekly_User_Count]),12)) Is there a possibility at DAX level to change the calculation to take only 10 weeks with best values for each month and country? So basicly Flag two worst Reported_Week (sum of all combination of User_Tier, User Group). I tried do it two ways and failed: Idea #1 - FAILED - Create Dax measure to detect lowest values. I used "MIN" Idea #2 - FAILED - Create a calculated Column to mark rows with lowest values. Again failed, aiming to use "EARLIER" Thank you gor helpSolved587Views0likes2CommentsReplacing EARLIER functionality to work in a measure
Hello, There was already existing topics about this subject but so far had no success with them. I would like to rank teams with selected season and gamedate with the following way: VAR _HomeGameNumber = // Game number based on gamedate only with no season condition RANKX(FILTER(TeamSchedule_, TeamSchedule_[HomeTeam] = EARLIER(TeamSchedule_[HomeTeam])), TeamSchedule_[gameDate], , ASC, Dense) VAR _HomeGameNumberPerSeason = // Game number based on gamedate and season RANKX(FILTER(TeamSchedule_, TeamSchedule_[HomeTeam] = EARLIER(TeamSchedule_[HomeTeam]) && TeamSchedule_[season] = EARLIER(TeamSchedule_[season])), TeamSchedule_[gameDate], , ASC, Dense) RETURN //The Measure should be able to switch between the two whether season is filtered //or not which is not possible with calculated column like below: IF(ISFILTERED(AuxSeason[Season]), _HomeGameNumberPerSeason, _HomeGameNumber) The goal here would be to replace the EARLIER() function to use in a measure. Would this work somehow with MAX() in a measure?770Views0likes2CommentsChange DAX calculated column using EARLIER Function
Hello, I recently read that you should not use the EARLIER function. I recently inherited a dataset file that uses this function and it keeps crashing, likely due to the EARLIER function. I am trying to convert this formula into the proper format using variables but I'm having some trouble. The current code is set up like so to get the cumulative balance as of the most recent invoice. How can I adjust this to remove the EARLIER function but get the same result? _Balance Cumulative = calculate(sum(Invoices[Balance]), ALLEXCEPT(Invoices,Invoices[Customer ID + Company Desc]), filter( all(Invoices[Invoice Date]),Invoices[Invoice Date] <= EARLIER(Invoices[Invoice Date])))Solved1.5KViews0likes2CommentsNeed a measure for comparing column values and returning a value based off repeated IDs
I have an ID and a Source column. The ID repeats and the available Sources are "Web" and "Other". User selects a value from a slicer on the page (from another column) that filters the IDs. If an ID is repeated and it belongs to web and also other, then the final result for that ID needs to be "Other". If the ID repeats and all rows belong to Web, then Web - but Other is higher than Web. I've tried the following measure and it works, but when I add other columns to my table view, it times out True Source = SWITCH( MINX( MyTable, SWITCH( MyTable[Origin], "Other", 1, "Web", 2, 3 ) ), 1, "Other", 2, "Web", "n/a" ) Then I tried this but EARLIER can only be used as a calculate column and the final result is wrong. True Source v2 = VAR RepeatedIDCount = COUNTROWS( FILTER( MyTable, MyTable[ID] = EARLIER(MyTable[ID]) ) ) RETURN SWITCH ( TRUE (), RepeatedIDCount > 1 && COUNTROWS ( FILTER ( MyTable, MyTable[ID] = EARLIER(MyTable[ID]) && (MyTable[Origin] = "Web" || MyTable[Origin] = "Other") ) ) = 2, "Other", RepeatedIDCount = 1 && MyTable[Origin] = "Web", "Web", "n/a" ) A sample of the data would be: ID Source 8145378 Web 8145378 Web 8145377 Other 8145377 Other 8145382 Web 8145381 Other 8145381 Web 8145370 Other 8145370 Other so the result table should be: ID True Source 8145378 Web 8145382 Other 8145377 Other 8145382 Web 8145381 Other 8145370 OtherSolved850Views0likes4CommentsReturn the value for the next minimum date if the value field is empty, and group by ID.
Hi, In dax, I would like to return the value for the next minimum date if the value field is empty, which should be group by ID. Also, need to return the coresponding value in the associated category colum. I have only one table and have attempted to use several measures, the example measure below does not work well when there are null values. Please help! CALCULATE ( MIN ( Query1[value]), FIRSTDATE ( Query1[date]) )1.8KViews0likes7CommentsDAX Calculated Column Sequence of Event Actions and Sessions
I have dataset with users actions logs. We have next data collection logic - every user have it own user_id and we record log of event actions during user session. user_id session_id dateTime event 1 aa 2023-01-01 13:12:11 login 1 aa 2023-01-01 14:12:10 buy 1 bb 2023-01-02 11:12:10 page 2 cc 2023-01-01 10:11:01 login 2 gg 2023-01-03 11:12:11 logout 2 gg 2023-01-03 13:11:03 click 2 gg 2023-01-03 14:10:07 logout The main goal is prepare output and add 2 calculated columns: 1. with events action sequence during every user session and 2. with session sequence during all user lifetime by SQL. Expected output: user_id session_id dateTime event event_seq session_seq 1 aa 2023-01-01 13:12:11 login 1 1 1 aa 2023-01-01 14:12:10 buy 2 1 1 bb 2023-01-02 11:12:10 page 1 2 2 cc 2023-01-01 10:11:01 login 1 1 2 gg 2023-01-03 11:12:11 logout 1 2 2 gg 2023-01-03 13:11:03 click 2 2 2 gg 2023-01-03 14:10:07 logout 3 2 What was done from my side: 1. Successfully create column with events action sequence during session Event Action Sequence = COUNTROWS ( FILTER ( CALCULATETABLE ( Sheet1, ALLEXCEPT (Sheet1, Sheet1[session_id]) ), Sheet1[Date] < EARLIER ( Sheet1[Date] ) || ( Sheet1[Date] = EARLIER ( Sheet1[Date] ) && Sheet1[Time Action] <= EARLIER ( Sheet1[Time Action] ) ) ) ) 2. Sessions Sequence Order By each user - calculated column not prepared - I stucked on it. Only prepared time for each session when it started (minimum time for each session) Min Session DateTime = CALCULATE( MIN(Sheet1[dateTime]), ALLEXCEPT(Sheet1,Sheet1[session_id]) ) So the main help request, how to solve this and create one more column with sessions sequene number orderd ascending by timestamp for each user. Sharing link to my pbix file https://drive.google.com/file/d/1807l9E07oNJv9l5rKWXKxDoc6rniyiYG/view?usp=sharing And sharing link to my sample: https://docs.google.com/spreadsheets/d/1bb7VId8lJ-NQkF43YS739kfc5Ur-1cGy/edit?usp=sharing&ouid=103990807236416334574&rtpof=true&sd=true626Views0likes1CommentSolving calcuated Column problem using dax
I am facing an issue with calculated column. This is sample data and here I want to achieve if isStoreClosed is Closed Status then I want to divide the Daily_Split Value by 6 and add this average value to the next 6 Retail Dates Daily_Split Value. I have created the Daily_Split2 Column and written the folloing dax to achieve the result Daily_split 2 = VAR Closed = CALCULATE ( SUM ( 'Daily Table'[Daily_Split] ) / 6, FILTER ( 'Daily Table', 'Daily Table'[IsStoreClosed] = "Closed" && 'Daily Table'[Store_Code] = EARLIER ( 'Daily Table'[Store_Code] ) && 'Daily Table'[Retail Date] = EARLIER ( 'Daily Table'[Retail Date]) && 'Daily Table'[Iteration] = EARLIER('Daily Table'[Iteration]) && 'Daily Table'[Category]= EARLIER('Daily Table'[Category]))) return IF ( 'Daily Table'[IsStoreClosed] = "Open", CALCULATE ( SUM('Daily Table'[Daily_Split])+ Closed, FILTER ( 'Daily Table', 'Daily Table'[Store_Code] = EARLIER('Daily Table'[Store_Code]) && 'Daily Table'[Retail Date] >= EARLIER('Daily Table'[Retail Date]) && 'Daily Table'[Retail Date] <= EARLIER('Daily Table'[Retail Date]) + 6 && 'Daily Table'[Iteration] = EARLIER('Daily Table'[Iteration]) && 'Daily Table'[Category]=EARLIER('Daily Table'[Category]) ) )) But this Code not giving me the desired result. I am not able to add the average value to the next 6 days. How do I fix this any help please.Solved1.6KViews0likes7CommentsFind duplicates between "date selected" and "date selected" - 30 days
Hi! 🙂 I have date filters (slicer) for year, month and day in a model that uses a table with [ID] and [Date] I want to show the duplicates between the "Date selected" and ("Date selected" -30 days) This is the table: If i select "December 1st, 2022" it should only show these: Thank you!1.1KViews0likes3CommentsCalculated column with sum as function
I'm looking for a formula that uses sums as logic that we know in Excel. I want to add a calculated column (orange) in the table below. That sums values of column value if the column values of date and color are equal. I once came across a formula with the EARLIER function, but I don't know the exact formula to get it to work.Solved1.9KViews0likes5CommentsDetermine the First of Two Actions
Hello, I have a table (‘1egh TSQL’) with columns of specific actions and dates on which those actions occurred. I used the formula below to calculate a new column called Fiscal Year, based on the following criteria: Must be the MAX Sequence for the project Must be the FIRST of the *Action “Application Finally Rejected” or “Application Approved” (whichever one occurs first) If the first two criteria apply and the *Date is 10/01/2020 – 09/30/2021, then Fiscal Year = “FY21” If the first two criteria apply and the *Date is 10/01/2021 – 09/30/2022, then Fiscal Year = “FY22” If the first two criteria apply and the *Date is 10/01/2022 – 09/30/2023, then Fiscal Year = “FY23” If nothing applies, then BLANK How can I correct my formula to only select the first action that occurs? In this example, FY22 should be listed next to the *Action “Application Finally Rejected”. Fiscal Year = VAR _sequence = '1egh TSQL'[Sequence] VAR _pjtnumber = '1egh TSQL'[FHA Number] VAR _action = '1egh TSQL'[*Action] VAR _table = FILTER ( '1egh TSQL', '1egh TSQL'[FHA Number] = _pjtnumber ) VAR _maxseq = MAXX ( _table, '1egh TSQL'[Sequence] ) RETURN IF ( _sequence = _maxseq && ( _action = "Application Finally Rejected" || _action = "Application Approved" ), SWITCH ( TRUE (), '1egh TSQL'[*Date] >= DATE ( 2020, 10, 1 ) && '1egh TSQL'[*Date] <= DATE ( 2021, 9, 30 ), "FY21", '1egh TSQL'[*Date] >= DATE ( 2021, 10, 1 ) && '1egh TSQL'[*Date] <= DATE ( 2022, 9, 30 ), "FY22", '1egh TSQL'[*Date] >= DATE ( 2022, 10, 1 ) && '1egh TSQL'[*Date] <= DATE ( 2023, 9, 30 ), "FY23", BLANK () ), BLANK () )Solved610Views0likes2Comments