difference
13 TopicsNew to Power BI and stuck trying to create date measures
Hello, I'm a complete Power BI newbie and trying to get my head round some of the features and some simple functions. I've managed to set up initial data source table and run create some initial visualisations on the data in the table, but now I'd like to take next step and do some more analysis relating to dates. In my initial table called "Live Campaign List" I have two date fields: - Date Started Planning - Date Sent to Current Position I'm trying to create measures using the DATEDIFF function to calculate: Power bi date difference (in days or months) between the two columns Power bi date difference from today (again in days or months) This is probably too advanced for me, given I can't master the basic functions, but ultimately I think it would be good to determine a categorisation of risk - Red/Amber/Green based on length of time difference (ie those with longer time gap and priority level of campaign). I have tried to use a DAX calcuation as follows: Date Difference Interval Measure = DATEDIFF('Live Campaigns List'[Date Started Planning], 'Live Campaigns List'[Date Sent to Current Position], Day) but I get an error message saying that in the "Date Started Planning" a single value cannot be determined. What am I doing wrong? How do I get the calculations to work? Thanks in advance Ed508Views0likes1CommentDAX Delta Issue - Difference Between Dates Not Working When Amount is Zero for Maximum Date Selected
I am trying to accurately calculate the difference in the amount sold between the most recent date selected and the oldest one. I used a DAX formula to create my Delta, and when calculating the difference between dates, my Delta works for most scenarios. However, there are cases where the measure is not working, specifically when we have 0 for the maximum date and a positive value > 0 for the minimum date. Here is the DAX I am using for my Delta, in my Measure: Diff = IF ( HASONEVALUE ( Table[Snapshot_Date] ), ( ( SUM(Table[Orders]) ) ), CALCULATE ( ( SUM(Table[Orders])), FILTER ( Table, Table[Snapshot_Date] = MIN ( ( Table[Snapshot_Date] ) ) ) ) - CALCULATE ( ( SUM(Table[Orders])), FILTER ( Table, Table[Snapshot_Date] = MAX ( ( Table[Snapshot_Date] ) ) ) ) ) The screenshot below shows that my Delta works perfectly when calculating the difference for the selected dates and rows below. Here follows one example where my measure is not working, where I have 0 for the maximum date and a positive value > 0 for the minimum date: For the highlighted row, the delta should be -0.1 instead. All other rows in this matrix are making sense. Can someone please help me out with this issue? Thank you 🐾1.1KViews0likes3CommentsCalculate difference between current and previous row with a condition
I have a table and need to calculate a difference between 2 rows with a condition that it only applies to Agregation Type = All Branches - YTD and it is a diff between fiscal month and fiscal month-1. In the table I added a column Diff that should show those results. # of rows will grow and is added on a weekly basis. Link_key Fiscal Year Fiscal Month Fiscal Week Agregation Type Applicants Diff 2021-1-All Branches - YTD 2021 1 4 All Branches - YTD 25 840 2021-2-All Branches - YTD 2021 2 8 All Branches - YTD 50 133 24 293 2021-3-All Branches - YTD 2021 3 13 All Branches - YTD 75 089 24 956 2021-4-All Branches - YTD 2021 4 17 All Branches - YTD 94 888 19 799 2021-5-All Branches - YTD 2021 5 21 All Branches - YTD 117 866 22 978 2021-6-All Branches - YTD 2021 6 26 All Branches - YTD 151 612 33 746 2021-7-All Branches - YTD 2021 7 30 All Branches - YTD 183 447 31 835 2021-8-All Branches - YTD 2021 8 34 All Branches - YTD 217 275 33 828 2021-9-All Branches - YTD 2021 9 39 All Branches - YTD 262 469 45 194 2021-10-All Branches - YTD 2021 10 43 All Branches - YTD 303 900 41 431 2021-11-All Branches - YTD 2021 11 47 All Branches - YTD 343 324 39 424 2021-12-All Branches - YTD 2021 12 52 All Branches - YTD 386 621 43 297 2022-1-All Branches - YTD 2022 1 4 All Branches - YTD 37 203 2022-2-All Branches - YTD 2022 2 8 All Branches - YTD 69 594 32 391 2022-3-All Branches - YTD 2022 3 13 All Branches - YTD 106 129 36 535 2022-4-All Branches - YTD 2022 4 17 All Branches - YTD 139 629 33 500 2022-5-All Branches - YTD 2022 5 21 All Branches - YTD 175 917 36 288 2022-6-All Branches - YTD 2022 6 26 All Branches - YTD 227 160 51 243 2022-7-All Branches - YTD 2022 7 30 All Branches - YTD 269 020 41 860 2022-8-All Branches - YTD 2022 8 34 All Branches - YTD 306 487 37 467 2022-9-All Branches - YTD 2022 9 39 All Branches - YTD 354 041 47 554 2021-1-All Branches - MTD 2021 1 4 All Branches - MTD 2021-2-All Branches - MTD 2021 2 8 All Branches - MTD 2021-3-All Branches - MTD 2021 3 13 All Branches - MTD 2021-4-All Branches - MTD 2021 4 17 All Branches - MTD 2021-5-All Branches - MTD 2021 5 21 All Branches - MTD 2021-6-All Branches - MTD 2021 6 26 All Branches - MTD 2021-7-All Branches - MTD 2021 7 30 All Branches - MTD 2021-8-All Branches - MTD 2021 8 34 All Branches - MTD 2021-9-All Branches - MTD 2021 9 39 All Branches - MTD 2021-10-All Branches - MTD 2021 10 43 All Branches - MTD 2021-11-All Branches - MTD 2021 11 47 All Branches - MTD 2021-12-All Branches - MTD 2021 12 52 All Branches - MTD 2022-1-All Branches - MTD 2022 1 4 All Branches - MTD 2022-2-All Branches - MTD 2022 2 8 All Branches - MTD 2022-3-All Branches - MTD 2022 3 13 All Branches - MTD 2022-4-All Branches - MTD 2022 4 17 All Branches - MTD 2022-5-All Branches - MTD 2022 5 21 All Branches - MTD 2022-6-All Branches - MTD 2022 6 26 All Branches - MTD 2022-7-All Branches - MTD 2022 7 30 All Branches - MTD 2022-8-All Branches - MTD 2022 8 34 All Branches - MTD 2022-9-All Branches - MTD 2022 9 39 All Branches - MTD 2022-1-SC Branches - YTD 2022 1 4 SC Branches - YTD 2022-2-SC Branches - YTD 2022 2 8 SC Branches - YTD 2022-3-SC Branches - YTD 2022 3 13 SC Branches - YTD 2022-4-SC Branches - YTD 2022 4 17 SC Branches - YTD 2022-5-SC Branches - YTD 2022 5 21 SC Branches - YTD 2022-6-SC Branches - YTD 2022 6 26 SC Branches - YTD 2022-7-SC Branches - YTD 2022 7 30 SC Branches - YTD 2022-8-SC Branches - YTD 2022 8 34 SC Branches - YTD 2022-9-SC Branches - YTD 2022 9 39 SC Branches - YTD 2022-1-SC Branches - MTD 2022 1 4 SC Branches - MTD 3 358 2022-2-SC Branches - MTD 2022 2 8 SC Branches - MTD 3 049 2022-3-SC Branches - MTD 2022 3 13 SC Branches - MTD 3 308 2022-4-SC Branches - MTD 2022 4 17 SC Branches - MTD 3 018 2022-5-SC Branches - MTD 2022 5 21 SC Branches - MTD 3 516 2022-6-SC Branches - MTD 2022 6 26 SC Branches - MTD 5 445 2022-7-SC Branches - MTD 2022 7 30 SC Branches - MTD 4 053 2022-8-SC Branches - MTD 2022 8 34 SC Branches - MTD 4 077 2022-9-SC Branches - MTD 2022 9 39 SC Branches - MTD 4 283 2022-10-All Branches - YTD 2022 10 42 All Branches - YTD 382 559 28518 2022-10-All Branches - MTD 2022 10 42 All Branches - MTD 2022-10-SC Branches - YTD 2022 10 42 SC Branches - YTD 2022-10-SC Branches - MTD 2022 10 42 SC Branches - MTD 2 548 2022-10-All Branches - YTD 2022 10 43 All Branches - YTD 391 349 37308 2022-10-All Branches - MTD 2022 10 43 All Branches - MTD 2022-10-SC Branches - YTD 2022 10 43 SC Branches - YTD 2022-10-SC Branches - MTD 2022 10 43 SC Branches - MTD 3 344 2022-11-All Branches - YTD 2022 11 44 All Branches - YTD 2022-11-All Branches - MTD 2022 11 44 All Branches - MTD 2022-11-SC Branches - YTD 2022 11 44 SC Branches - YTD 2022-11-SC Branches - MTD 2022 11 44 SC Branches - MTDSolved1.2KViews0likes3CommentsDifference between two values when one of the value is blank
Hi All, I am a newbie to PBI. I have run into this issue with my matrix visual Delta is calculated basically as the difference between Date 1 & Date 2 using DAX. If there is value in Date 1 (say 100) and a value in Date 2 (70) the Delta is 30. But like the table below sometimes the value in Date 1 is blank/empty/null and Date 2 has a value and vice verse . If that is the situation I need the Delta to show up as a negative and positive value respectively. For example (see first 2 rows...3rd and 4th row are working as expected) Date 1 Date 2 Delta 100 -100 100 100 90 60 30 60 90 -30 Can someone help with this? Thanks!Solved636Views0likes1CommentCalculate difference in statuses
Hi all, I have a dataset table like the one below: ID Initial Status Final Status a1 x x a2 y x a3 z y and I have to create a visualization like this one: Initial Status Difference x (number of IDs with final status = x) - (number of IDs with initial status = x) y (number of IDs with final status = y) - (number of IDs with initial status = y) z (number of IDs with final status = z) - (number of IDs with initial status = z) How can I calculate the difference? Thank you in advance. FabioSolved1.1KViews0likes2CommentsCalculate the difference between values of a column based on a number of rows
Hello, I'd really appreciate you can help me. I have a table like this one: Basically, it's showing the number of cases by day and country. The list has many rows. I need to add a column that shows the difference between the number of cases of that day and the number of cases 14 days before. I'm not familiar with DAX, and I know neither how to refer to the specific value of a cell in a column nor how to specify the number of rows behind to look for the difference's value. I really appreciate any help you can provide. Best PedroSolved1.9KViews0likes2CommentsCount Difference between dates broken out by month
Is there a way to calculate the difference between two dates but break them out by months? My table example is: ID Date Start Date End Duration 123 12/11/2018 16/11/2018 5 123 02/01/2019 07/01/2019 6 1003 03/06/2019 07/08/2019 66 This count works fine for short dates within the same month but I'm hoping to get a month count between the start and end dates? So I'm hoping to have some sort of breakout/ split to show: ID June July August 1003 28 31 7 Thanks.Solved1.1KViews0likes2CommentsCalculating value differences for each week
I have some 'availability' numbers (a percentage) for a bunch of machines on a weekly basis. My raw CSV data looks like this: Machine,WW,Availability A,WW35,0.9 B,WW35,0.95 C,WW35,1 D,WW35,0.87 A,WW36,1 B,WW36,1 C,WW36,0.84 D,WW36,0.94 A,WW37,0.75 B,WW37,0.98 C,WW37,0.91 D,WW37,0.89 A,WW38,1 B,WW38,0.88 C,WW38,0.99 D,WW38,0.95 Data source is updated weekly and new Work Week (WW) availability data is added for each machine. A machine is deemed 'Pass' if the availability for that week is > 90%. I calculate the 'Pass' measure as below. Pass = VAR varCount = CALCULATE(COUNTA(data[Availability]), data[Availability] > 0.9) RETURN IF(varCount = BLANK(), 0, varCount) Pass count for each machine for each week, displayed in a matrix, looks like this (given above data): Now, I want to calculate some figures for these pass values for each machine. My actual needs are a bit complex, but few of the most basic things I wanted calculated are shown below. New Pass Number of total machines for each week that passed, but failed previous week. New Fail Number of total machines for each week that failed, but passed previous week. Steady Number of total machines for each week that the condition didn't change. To better illustrate, I put my desired results in an Excel file: As mentioned at the beginning of the post, my source CSV is updated with new data each week, so as time goes on I will have more [WW] columns added in my PowerBI matrix. Given this I don't quite know how I can calculate the above values dynamically without hardcoding anything. Is this possible?1.5KViews0likes3CommentsGet difference in Matrix between two dates of a slicer (show zeros)
Hi everyone, I'm having problems creating a measure that can calculate the difference between 2 dates in a slicer, i created this one but doesn't seems to work like i would want: DELTA2 = VAR LASTDAY = [HOY] VAR PREVDAY = [ayer] VAR TOODAY = CALCULATE(SUM('DATA BASE'[Tons]),'DATA BASE'[FECHA DE CAPTURA] = LASTDAY,VALUES('DATA BASE'[OP])) VAR YESTERDAY = CALCULATE(SUM('DATA BASE'[Tons]),'DATA BASE'[FECHA DE CAPTURA] = PREVDAY,VALUES('DATA BASE'[OP])) RETURN TOODAY-YESTERDAY where: [HOY] = CALCULATE(MAX('DATA BASE'[FECHA DE CAPTURA]),ALL('DATA BASE')) and, [ayer] = CALCULATE(MAX('DATA BASE'[FECHA DE CAPTURA]) - 1,ALL('DATA BASE')) my result is this: it only kinda works with the last 2 dates, also i filtered the results of DELTA2 = 0, so it only displays the changes between days. I would like to reach a matrix like this (whatever date i choose, will be always one day and the next): if anyone can help me, i would really apreciatted.986Views0likes1CommentDifference betweeen two cummulative values
Hi, everyone I have been struggled with the phormula to get a difference between two cummulative values and I'm stuck. I want to show in a card the difference between two cummulative values depending on the dates selected by slicers. Data structure: Date Quantity Cummulative Quantity 01/02/2020 15 15 02/02/2020 7 22 03/02/2020 2 24 I have created a measure to get the cummulative value: Cummulative Quantity = CALCULATE(SUM(Sales[Quantity]);FILTER(ALL(Calendar); Calendar[Date] <= MAXX(Calendar;Calendar[Date]))) The goal is showing the cummulative difference in a card depending on a date slicer. Examples: Date slicer values Difference From 01/02/2020 to 02/02/2020 7 From 01/02/2020 to 03/02/2020 9 From 02/02/2020 to 03/02/2020 2 Can anyone help me, please?.. Thanks in advance,Solved1.7KViews0likes5Comments