dax filter issues
3 TopicsFilter in measure does not work properly exceptionally in the last year
Hi I have created a measure that calculates the income in terms of year to date. It works properly for all years in my data, but only in the last year the result is not correct. I have digged into my data and understood that it does not take into effect the last few days in the latest month (which is in May 2024). For previous years it the results of absolutely correct. Only in the year 2024 the results are wrong! Why it works correctly for all years except for 2024?? why it misses the last few days? GBV = VAR year_in_context = SELECTEDVALUE('Date'[Year]) VAR month_in_focus = MONTH(TODAY()) VAR day_in_focus = DAY(TODAY()) VAR last_day = DATE(year_in_context, month_in_focus, day_in_focus) VAR first_day = DATE(year_in_context, 1, 1) VAR Result = CALCULATE( SUM('bookings'[Price]), FILTER( 'bookings', 'bookings'[BookingDate] >= first_day && 'bookings'[BookingDate] <= last_day )) RETURN Result Many thanks in advance for your help!Solved740Views0likes2CommentsAdd Ranking Column with filters
Hi Everyone, I need some help creating an index column using DAX. I have a table named ACCOUNTEXCEPTION with columns [ID] , [Key] and [Status]. I first want to create a ranking column, that sorts records in ascending order based on [ID] grouped by [Key]. To achieve this I can use the following code which works perfectly. Order by key = VAR CurrentKey = 'ACCOUNTEXCEPTION'[Key] VAR CurrentID = 'ACCOUNTEXCEPTION'[ID] RETURN CALCULATE ( COUNTROWS('ACCOUNTEXCEPTION'), FILTER ( ALL('ACCOUNTEXCEPTION'), 'ACCOUNTEXCEPTION'[Key] = CurrentKey && 'ACCOUNTEXCEPTION'[ID] <= CurrentID ) ) Now the issue I can't seem to solve is how to apply this ranking to only certain keys that meet a criteria. If the first ID within a key has the status = 'Research', then I want to go ahead with the ranking, otherwise I want to leave it blank. Below is how the final table should look like: Key ID Status Order by Key A 1 Research 1 A 2 In progress 2 A 3 Completed 3 B 1 Initiated B 2 In progress C 1 Research 1 C 2 Completed 2 Any help would be appreciated! ThanksSolved1.1KViews0likes4CommentsALLEXCEPT and ALL function does not work as I expected in DAX
Hi Everyone, I'm trying to use All/Allexcept functions in some calculations for some case scenarios. I was working with Qlik & QlikSense before and this is easly applicable on Qlik but I could not manage to get this done on PowerBI. This may not be applicable on powerbi or I may not achieve to do it. Eveything explained on the last page(ALL & ALL EXCEPT Examples), but I will give summary here again. (PBIX file : GoogleDriveLink) Page : ALL & ALL EXCEPT Examples What I'm trying to do is, I want to put a few measure on a table and when I make a selection from a field, I want only some calculations get affected from that selection, and some others don't. For example, I will put Master Date as dimension and 3 different calculation on the table. I will make a selection from Service Category field and only 1th. measure will be affected from that selection and others don't. Then I will make another selection from Availability field, then 2.th measure will be affected from the selection etc... I have 4 tables. Appoinment, Marketing, Utilization, Availability. All those 4 tables merged into appointment table. Measure 1: Calculation gets affected from only determined fields in the all except function. Test Appointment Qty = CALCULATE(sum(Appointment[m_appointment_qty]) ,ALLEXCEPT(Appointment ,Appointment[dim_country_id] ,Appointment[dim_country] ,Appointment[dim_master_date] ,Appointment[dim_service_category] ,Appointment[dim_promise_met]) ,Appointment[table_type]="Appointment" ,Appointment[dim_calculation_type]="Original" ) Measure 2: Calculation will not be affected from the determined field selections. Test2 Appointment Qty = CALCULATE( sum(Appointment[m_appointment_qty]) ,ALL(Appointment[data_flag]) ,ALL(Appointment[Availability]) ,ALL(Appointment[dim_day_diff]) ,ALL(Appointment[cleaner_id]) ,Appointment[table_type]="Appointment" ,Appointment[dim_calculation_type]="Original" ) Those calculations works fine if I don't put any dimension into the table but it does not work if I put any dimension. I tried it with and without FILTER function in the calculation but I could not manage this to work with FILTER function. When I put FILTER in dax formula, FILTER function does not allow me to put multiple dimensions to tell the calculation not to affect from any selection. More detailed explanation and use cases are on the page in PBIX file. I'd be so happy if you see the file and help me to write the correct DAX formula. Thanks for your support already. Table 2 Works fine but Table 1 will not be shown if I make any selection. I attached the uses cases as well.1.8KViews0likes6Comments