count rows
4 TopicsCount number of rows between transaction types
I have a calculated table that returns each purchase and sale transaction by stock ticker by date. Then I created a helper column that returns whether each row relates to a "Purchase" transaction, a "Sale" transaction, or to both ("Purchase/Sale"). ADDCOLUMNS( SUMMARIZECOLUMNS( dAssets[Ticker], dDates[Date], "Purchased", [Shares purchased], "Sold", [Shares sold], "Balance", [Shares balance] ), "Transaction", SWITCH( TRUE(), [Purchased] <> BLANK() && [Sold] = BLANK(), "Purchase", [Purchased] = BLANK() && [Sold] <> BLANK(), "Sale", [Purchased] <> BLANK() && [Sold] <> BLANK(), "Purchase/Sale" ) ) What I need is a calculated column that indicates how many rows (NEGATIVE) above each "Sale" row the last "Purchase" sale row had taken place. Obviously, in case a row refers to a "Purchase" transaction then return "null/blank". And for those rows that refer to dates on which both "Purchase" and "Sale" took place then return ZERO. One requirement must be followed: making sure such row count takes place within each group of tickers. Below is a screenshot of the table produced by the above code and I hardcoded in red the desired calculated column output. This seems simple but I just can't get a way to make it work... Right out of the gate I get the error "the column 'Transaction' cannot be found or may not be used in this expression" when trying to generate a calculated column with the Date of the last "Purchase" transaction prior to each respective "Sale". VAR Tbl = ADDCOLUMNS( SUMMARIZECOLUMNS( dAssets[Ticker], dDates[Date], "Purchased", [Shares purchased], "Sold", [Shares sold], "Balance", [Shares balance] ), "Transaction", SWITCH( TRUE(), [Purchased] <> BLANK() && [Sold] = BLANK(), "Purchase", [Purchased] = BLANK() && [Sold] <> BLANK(), "Sale", [Purchased] <> BLANK() && [Sold] <> BLANK(), "Purchase/Sale" ) ) RETURN ADDCOLUMNS( Tbl, "Last Purchase Date", VAR Ticker_Ref = dAssets[Ticker] VAR Date_Ref = MAX( dDates[Date] ) RETURN CALCULATE( MAXX( dDates, dDates[Date] ), dAssets[Ticker] = Ticker_Ref, dDates[Date] <= Date_Ref, [Transaction] = "Purchase" || [Transaction] = "Purchase/Sale" ) )405Views0likes1CommentDIstinct Count of Category Name Filtered by One of Multiple Demand Columns
Hi everyone, I'm unable to get the correct distinct count of my product based on whether there is current demand, while I have two different demand columns which do not overlap in row entries. I provide simplified data in which I want it to be calculated like the following: As you can see, I want my Product column to be distinctly counted based on whether it is also populated by the Current Demand measure (this measure directly refencing a demand column in my data, since I want to create an explicit rather than implicit measure for Excel use). My thinking has been to create the following: Count=CALCULATE( DISTINCTCOUNT(ProductTable[Product],[Current Demand] <> BLANK()). However, it is not working. Please note that I don't have access to the most recent DAX functions such as DISTINCTCOUNTNOBLANK, so I hope there is still a way around this. Any help will be much appreciated.Solved1.4KViews0likes2CommentsDAX how to count number of rows with a value
I have a table similar where I need to count up number (by month) of rows that have Y value in them. I tried below but it is not returning values at all. I am able to count rows but I need to count only the Y rows. What do I have wrong? #Y = COUNTROWS(filter(TABLE,TABLE[OverThres]="y")) thanks! date over threshold amount 1/1/2023 y 5,000.00 1/2/2023 n - 1/3/2023 y 2,000.00 1/4/2023 y 6,000.00 1/5/2023 n 100.00Solved1.3KViews0likes2CommentsNeed to remove values from dynamic table in DAX percentile Calc
Hey, I have a fomula that is calcualting the percentile of a value, however, I need to remove any row that is equal to "0" as these results should not get a percentile rank and are skewing the rating of the other values. Any help would be greatly appreciated, I'm guessing there needs to be another filter where the Employees[Total Handled Rate 2022] <> 0 but can't seem to figure it out. Formula is below; Total Handled Rate 2022 Percentile = VAR Adj2022 = MIN(Employees[Total Handled Rate 2022]) RETURN IF( HASONEVALUE(Employees[Code]), COALESCE( DIVIDE( CALCULATE( COUNTROWS(Employees), FILTER( ALLEXCEPT(Employees,Employees[Department]), Employees[Total Handled Rate 2022] > Adj2022 ) ), CALCULATE( COUNTROWS(Employees), ALLEXCEPT(Employees,Employees[Department]) ) ), 0 ) ) ThanksSolved809Views0likes3Comments