lastdate
8 Topicscount rows on condition only for last date
Hi, I'm beginner in DAX. I've got a dataset like product, date, completed (a boolean value True/false), amount. I need to get the count of not completed rows where completed is false only for the last date by products. product, date, completed product1, 2023-12-01, false product2, 2023-12-01, false product3, 2023-12-01, true product4, 2023-12-01, false product3, 2023-12-02, true product3, 2023-12-03, true product2, 2023-12-03, false product4, 2023-12-04, true product3, 2023-12-04, false product3, 2023-12-05, false At 2023-12-05 (or after if no more data are added) I have product1, 2023-12-01, false product2, 2023-12-03, false product3, 2023-12-05, false product4, 2023-12-04, true My goal is to have a count of the completed_0 and completed_1. something like : count_completed = 1 and count_not_completed = 3. And when visualising by product, I like to have product1 : 1 not completed, 0 completed product2 : 1 not completed, 0 completed product3: 1 not completed, 0 completed product4 : 0 not completed, 1 completed When changing the global filter on date to go back in time, the "last date" should change the results according to the selection. I tried many approach using CALCULATE, LASTNONBLANKVALUE ... without result. Is a DAX approach is possible to answer this question ? what measure should I use to get the result I need ? Thanks for your help. Stéphane745Views0likes3CommentsLAST DATE WITH SALE BY CUSTOMER
Hi! I have a situation, i hope anybody could help me. I have 2 tables, table A kardex customers. And table B sales by date and customer's. tableA. Table B. I need a measure or calculated column in table A, that showme the last date of sales of that customer, like green column: thank you.783Views0likes3CommentsCompairing a date measure to a date column in the same dimension table
I'm trying to create a filter to determine the inclusion or exclusion of records in a dimension table based on whether the Threshold Date for each record is less than the calculated Last Date measure. There's probably a much more intelligent way to do this, but I'm kind of stumbling my way around here and am not very good with DAX. The threshold date column is native to the imported Excel spreadsheet that I'm using as a dimension table; the measure is based on a calendar dimension table imported from a data warehouse, and I'm selecting date ranges using a date slicer in the report. I've tried calculating the Last Date two different ways: 1) Using CALCULATE and LASTDATE: CALCULATE(LASTDATE('Calendar'[Date (EDW)]), ALLSELECTED('Calendar'[Date (EDW)])) 2) Using MAXX: MAXX(ALLSELECTED('Calendar'),'Calendar'[Date (EDW)]) Both work fine as measures. If I try to convert them into dimensions (or create them as columns instead of measures), they'll ignore the slicer and just return the last date from my entire calendar table. Similarly, if I try to create an IF statement returning a one or zero based on whether the Threshold Date falls before the Last Date, the formula returns a value of one for all records in the dimension table with a Threshold Date that falls before the last date in my calendar table. Is there a way to compare my Last Date and Threshold Date that will still apply the slicer to the Last Date? I can't create an active relationship between the calendar dimension table and the dimension table containing Threshold Dates because the calendar dimension table already joins to two fact tables which then join to the dimension table containing Threshold Dates.Solved1.9KViews0likes7CommentsSum previous complete week and return zero for schools that had no values in previous week
I am trying to sum the number of positive COVID cases at local schools for the most recent complete week (a complete week ending on Sunday). I update the data each week so I am trying to build a formula that updates the “new cases last week” value automatically. The challenges: Some schools report new cases daily while others do not report any data for an entire week. For schools that did not report anything the previous week, my (broken) formula returns the value from the most recent week available for that school, even if it is not from the previous week. That is not what I want! If a school made no reports last week, I’d like the formula to return “0”. The MAX function and LASTDATE function filter to the last week of data in my dataset, but I run this report on Wednesday so the MAX date and LASTDate target the incomplete current week. I want the most recent complete week of data. In the end, I want a table with a row for each school that shows the number of total cases and the number of new cases last week. I tried many, many calculations. Here are a couple of my failures. I was trying to use minus 7 to bring me to the previous complete week. In the second example, I use a date table. Example 1 NEW positive_ALL = CALCULATE(SUM(schools[positive_all]), LASTDATE(schools[Week end date]-7)) Example 2 NEW positive_ALL = CALCULATE(SUM(AllSchools[positive_ALL]),('AllSchools'[Week end date]= (MAX(Datetable[WeekEndDate]-7)))) Here is a link to some sample data I uploaded on WeTransfer. In the sample, there are at least two schools, Emma Willard and Catholic Central High, that did not submit data for the most recent week, which ended on Oct. 31. Thanks for any guidance you may provide.Solved938Views0likes2CommentsLASTDATE Not working as required
Hi guys, I am trying to retrieve the most recent QTY On Hand for each product in my inventory but the trouble I am having is that for whatever reason, some of these products can be present on multiple order lines of the same order with the same order date and time making it difficult to calculate the most recent QTY On Hand. Below, is an example of such case. My formula is the following : LAST INVENTORY VALUE = VAR X = CALCULATE(MAX(INTRAN00[TXQOH]),LASTNONBLANK(INTRAN00[TRANSACTION DATE],1)) RETURN X Highlighted in Green is the value I want to retrieve but my formula currently retreives 298. But , Based on the time reference (TXTIME) the most recent transaction is 7394480 *TXORD#) focusing on the last line (TXLINE) of that order which is 4. So essentially my formula needs to take into account order time as well as the very last line number in instances such as these. Any recomendations ?1.1KViews0likes1CommentEnd of Month in Columns
Hello Team, I want to display the values of the last day of every month in columns. Is there a way to do that ? So basically, I want a table With name of the parameters on the left most column and corresponding values of last day of every month in the year. Parameter 12/31/2020 1/31/2021 2/28/2021 3/31/2021 ... ... I have tried LAST DATE and ENDOFMONTH but somehow they dont seem to work616Views0likes1CommentDirect Query Calculate LastDate issue
I am creating a visual for a Direct Query. I need to return the LastDate from my Date Dimension table (Rolling Calendar) and pass that into my CALCULATE Function to sum the TotalDrawers for that date. I keep getting a locking error. When I check it in DAXStudio it indicated there is an issue with LASTDATE. Seems that this has to do with the LASTDATE being used in a CALCULATE function on a Direct Query. Any thoughts on how to resolve the issue? WTDDrawers = VAR SelectDate = LASTDATE( 'Rolling Calendar'[Calendar Date] ) VAR DayNumberOfWeek = WEEKDAY ( LASTDATE ( 'Rolling Calendar'[Calendar Date] ), 1 ) //VAR TestFirstDate = DATEADD ( SelectDate, ( -1 * DayNumberOfWeek ) + 1, DAY ) RETURN CALCULATE ( SUM ( _AE1WeekComp[TotalDrawers] ), DATESBETWEEN ( 'Rolling Calendar'[Calendar Date], DATEADD ( SelectDate, ( -1 * DayNumberOfWeek ), DAY ), SelectDate ) )1.4KViews0likes5Comments