" error handling"
8 TopicsHelp with error: DAX comparison operations
Hello, I've been searching this forum for help, but haven't managed to find a solution to my problem. I am trying to create a calculated column called HMG. HMG should equal 1 only if both of the following conditions are met: SAMPLE =1 AND State_Clean = "WA". Otherwise, the value for HMG should equal 0. I'm using the following syntax and getting the following error: HMG = if( Interaction_Table[SAMPLE]=1 & RELATED(Client_Table[State_Clean])="WA",1,0) ERROR: DAX comparison operations do not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values. I would love some help adjusting my syntax to work. SAMPLE is a calculated column so I'm not sure how to tell what type it is, but I'm guessing it's numeric since the values are 1 and 0. I assume State_Clean is a string. Thank you!!Solved898Views0likes2CommentsDax formula not working
I have created the below dax, to try to get in how many days an order is late. So the loic goes like this: if the order is created before 8pm Monday to Saturday, then it should be fulfilled the same day. If an order has been fulfilled after 8pm then the cut-off will move to the next day, so is like the order was made the next day before 8pm. For Saturday - Sunday orders after 8 the cut-off moves to Monday as Sunday is not a working day. Sunday cannot be counted as failed day, as is not working day. So ideally what I need is how many days have passed since an order that have not been fulfilled on time, for the same day fulfillments works however for some orders created before 8pm and fulfilled the next day or any other day shows like 0 also. I can't figure it out where is the issue. Any help will be highly appreciatted. DaysLate_Express = VAR CreatedTime = MAX(Orders[AdjustedTime]) VAR FulfilledTime = MAX(Orders[Fulfilment Date Adjusted]) -- Get the date values from the datetime VAR CreatedDateOnly = DATEVALUE(CreatedTime) VAR FulfilledDateOnly = DATEVALUE(FulfilledTime) -- Get the created day of the week (Monday = 1, Sunday = 7) VAR CreatedDay = WEEKDAY(CreatedDateOnly, 2) VAR FulfilledDay = WEEKDAY(FulfilledDateOnly, 2) -- Check if the order was created before or after 8 PM VAR IsAfter8PM = IF(HOUR(CreatedTime) >= 20, 1, 0) -- Adjusted created date based on creation time VAR AdjustedCreatedDate = IF( IsAfter8PM = 1, IF(CreatedDay = 6, CreatedDateOnly + 2, -- Saturday after 8 PM moves to Monday IF(CreatedDay = 7, CreatedDateOnly + 1, -- Sunday moves to Monday CreatedDateOnly + 1 -- Weekday after 8 PM moves to the next day )), CreatedDateOnly -- No adjustment for orders created before 8 PM ) -- Check if the fulfilled date is the same day as the adjusted created date VAR IsSameDay = CreatedDateOnly = FulfilledDateOnly -- Calculate the number of days late VAR DaysLate = IF( NOT IsAfter8PM && NOT IsSameDay, DATEDIFF(AdjustedCreatedDate, FulfilledDateOnly, DAY) - DIVIDE(COUNTROWS( FILTER( {1, 2, 3, 4, 5, 6, 7}, -- Days of the week (1 = Monday, ..., 7 = Sunday) [Value] = 7 && [Value] >= WEEKDAY(AdjustedCreatedDate, 2) && [Value] <= WEEKDAY(FulfilledDateOnly, 2) ) ), 1), -- Count the number of Sundays in the range 0 -- Return 0 if the order was fulfilled on the same day or if SLA was met ) -- Return the days late if SLA not met, otherwise 0 RETURN IF(NOT IsSameDay && NOT IsBlank(DaysLate), DaysLate, 0)Solved757Views0likes2CommentsI need a DAX measure to calculate an average of scores by selected agents over selected months
I have been trying to use the following measure to create a column in my Visual Table to give me the average of each agent for a group of selected months. If I change the slicer for different months it gives me the average for each month instead of averaging them together. Can you help?: Average Agent Score for Months = CALCULATE( average(TestScores[Score]) ,FILTER(ALL(TestScores), TestScores[Agent] IN VALUES(TestScores[Agent])) ,FILTER(ALL(TestScores), TestScores[Month] IN VALUES(TestScores[Month])) ) Here is what I get: Example: For Barney, I expect to see the average of 39 ((39+48+34)/3) in all three places. and if I change the months, I expect to see the average recalculated for the new group of months. I am using a test table of data: Month Agent Score Team JAN Bill 32 Barney FEB Bill 32 Barney MAR Bill 37 Barney APR Bill 33 Barney MAY Bill 48 Barney JUN Bill 40 Barney JUL Bill 37 Barney AUG Bill 45 Barney JAN Mary 43 Barney FEB Mary 32 Barney MAR Mary 50 Barney APR Mary 43 Barney MAY Mary 46 Barney JUN Mary 50 Barney JUL Mary 46 Barney AUG Mary 50 Barney JAN Raval 46 Mavis FEB Raval 41 Mavis MAR Raval 43 Mavis APR Raval 43 Mavis MAY Raval 37 Mavis JUN Raval 39 Mavis JUL Raval 35 Mavis AUG Raval 30 Mavis JAN Luego 30 Mavis FEB Luego 33 Mavis MAR Luego 33 Mavis APR Luego 50 Mavis MAY Luego 41 Mavis JUN Luego 34 Mavis JUL Luego 36 Mavis AUG Luego 38 MavisSolved1.7KViews0likes7CommentsHow can I find out why standard deviation measure doesn't work?
Hello Everyone, I have 3 tables and appended on the top of each other. Each table I can identify with table_type column, so that I can use necessary aggregations by filtering them. They have attribute and value column so I can fetch the data in dax (please see below) VAR _table = ADDCOLUMNS( 'Appended Table', "IsNumeric", IF( ISERROR( VALUE('Appended Table'[Value]) ), 0, VALUE('Appended Table'[Value]) ), "Table Type", 'Appended Table'[Table_Type], "UID", 'Appended Table'[Attribute] ) VAR _measure = STDEVX.P( FILTER(_table, [Table Type]= "My Table"), [IsNumeric] ) RETURN _measure okay I realize it works when I filter one category which values are 0.170289855 and 0.239130435 and their standard deviation is 3.44% and when I filter another category which values are 0 0.006122449 0.020408163 -0.037037037 -0.048247999 -0.092592593 -0.100040016 -0.123193614 -0.145365551 0.183673469 -0.195918367 0.285714286 0.287504476 -0.306122449 -0.322942857 0.36122449 -0.413793103 -0.624752187 and measure returns = 6.05% however when I look at excel and calculated std.p = 24.68% I need to figure it out somehow... Since I'm sure I'm working on the right selected (filtered data) and not able to dissect the formula and try to replicate step by step... I need your help= any ideas, directions will be much appreciated. thank you !866Views2likes3CommentsIssue with IFERROR Not Catching Errors Row by Row When Using YIELD in Power BI
Hello, I'm experiencing an issue with the YIELD function in Power BI. I'm trying to calculate the yield, but it seems that IFERROR is not catching errors on a row-by-row basis and assigning values when an error is detected. Here are snapshots of my Excel and Power BI setup: Excel Snapshot: Power BI Snapshot: The formula I'm using in Power BI is: YIELD = YIELD(test[SETTLEMENT_DATE], test[MATURITY], test[COUPON], test[LAST_PRICE], test[PAR], test[Freq]) All columns seem to have the correct data types, but I still encounter #ERROR values. In Excel, I get #NUM! and some valid yield values as expected. However, in Power BI, I was expecting it to show results row-by-row and leave blank if there's an error, instead of showing an error for the whole column. I tried wrapping the YIELD function with IFERROR, but it doesn't seem to handle the errors as expected. Is there any way to make Power BI show the result row-by-row and leave the cell blank if it encounters an error? Attached the data here for reference SETTLEMENT_DATE MATURITY COUPON LAST_PRICE PAR Freq 07/30/2024 07/31/2024 11.00% 9 100 4 07/30/2024 08/31/2024 9.40% 94 100 4 07/30/2024 08/31/2024 9.40% 95 100 4 Thank you!Solved791Views0likes1CommentDAX Error SUMX
Hi, I'm working on a DAX and not getting the expected results. It seems that at a line item level it is calculating correctly however, at the total level it is not summing but performing the calculation at total level. which means it is ignoring the If function. Here is my DAX: SUMX('Calendar',IF(NOT(ISBLANK([Wages on Flat Units])), CALCULATE(SUM('WagesHomeCC and Fringe Line Items'[Amount]),Account_Map[Lvl 2] = "Total PR Tax"), 0)) Results: Power BI is including the $67 at the total level even though there are no wages. Does anyone know how to solve this in Power BI? Cost Ctr Calendar Wages on Flat Units PR Tax 1 2024-01 5,276 441 1 2024-02 15,288 1,305 1 2024-03 5,276 581 1 2024-04 5,426 663 1 2024-05 1 2024-06 67 1 2024-07 1 2024-08 Total (Expected) 31,265 2,990 Total (Power BI) 31,265 3,056Solved1.8KViews0likes4CommentsDynamic Dax Measure
Hi guys, I am working on a dynamic dax measure which I like to use for one visual. Basically I want to have one visual that shows the costs. Based on the dynamic filter which I put into the x-axis field, the user is able to filter by various categories which come from various data sources. All are string values e.g by category, by city etc. I tried so many things but the Code just doesnt work. I dont want to create a extra table and merge all these categories inside, I just want it to work how it is. Thank you in advance! DynamicMeasureNEW = VAR SelectedColumn = SELECTEDVALUE(DynamicTable[Column1]) RETURN SWITCH ( SelectedColumn, "Delay Reason", VALUES(MedicallyFitForDischarge[FIT_REASON]), "Care Group", VALUES(Look_New_Trust_Hierarchy[CARE_GROUP]), "Specialty", VALUES(Look_Specialty[Specialty Description]), "Ward", VALUES(MedicallyFitForDischarge[LOCATION]), BLANK() // Return BLANK() for unmatched cases )444Views0likes1CommentKnow how many users news repeat an order
Good morning everyone, I'm facing a problem in my power BI model and I'm looking for some help. I have a customer table where I have all the customer ID with every transaction (order) they made during a period. So I have one line per transaction. I also have a column to know if is the first time a customer is purchasing with a boolean of Y/N. The problem I'm facing is that if I want to know the NEW customers I have in my table, I just need to do a calculate with a filter = Y in the column where I notice if it's the first purchase; however, I want to know how many times a NEW customer bought me in a filter date selection. For example, a customer buys for the first time in May 2023, and makes another purchase in July 2023. I want to know, that user is new and he did 2 purchases in that period. If I apply a filter in the page to know all the users news, I miss that second purchase that have a N in the first purchase column, and I don't want to lose it. Any ideas? Kind regardsSolved752Views0likes3Comments