"dates"
22 TopicsStruggling to apply filters in my DAX
Hello, I'm really struggling on how to make my slicers work. So, I have an Employment table, with two date columns: Hire Dates and Termination Date. I have an active relationship with my Calendar[Date] and Employment[Hire Dates], and an inactive relationship with my Calendar[Date] and Employment[Hire Dates]. Below is my current DAX formula. My problem is, if I add the a Job Title or Location in my slicer or in my visuals, it doesn't work correctly. Both these columns can be found in my Employment table. Please let me know what I'm doing wrong. Thank you! Opening Headcount = VAR PeriodStartDate = MIN('Calendar'[Date]) // Gets Jan 1st of the selected period RETURN CALCULATE( COUNT(Employment[Employee #]), FILTER( ALL(Employment), // 1. Must be hired ON or BEFORE the start of the period Employment[Hire Date] <= PeriodStartDate && // 2. Must NOT be terminated BEFORE the start of the period // Logic: Either termination is blank OR it happens AFTER the start date ( ISBLANK(Employment[Termination Date]) || Employment[Termination Date] >= PeriodStartDate ) ) ) daxSolved574Views0likes2CommentsVariance between Two Years on same Date Axis using same Amount Column
Unfiltered: Filtered: The task at hand is simple, take the 2025 values (Food Revenue, Beverage Revenue, etc.) and subtract the 2024 values from the correlated field (first screenshot). However, I am running into issues with the date axis it lies on and how to correctly display only the months needed. The formula used takes the sum of the current year (CY, Dec 2024 - Mar 2025) for a specific account, and subtracts it from the balance of the prior year (LY, Dec 2023 - Mar 2024). This does in fact work, as the values shown in the second screenshot are correct for Food Revenue Variance for the months needed thus far (fiscal year starts in December, so December 2024 - March 2025). However, when I filter to just show the months needed, the values revert to only show the balances correlated with the current year (CY). Any ideas on how to show this variance correctly? In layman's terms, basically need to INCLUDE data from all months relevant (Dec 2023 - Mar 2024, Dec 2024 - Mar 2025), but I only need to DISPLAY the months with the correct values for variance (Dec 2024 - Mar 2025). DAX measure: VARI Food Revenue = VAR CY = CALCULATE(SUM(ConsolidatedReport[Amount]), ConsolidatedReport[GLAccount] = "450000", DateDim[CurrentFiscalYear] = 0) VAR LY = CALCULATE(SUM(ConsolidatedReport[Amount]), ConsolidatedReport[GLAccount] = "450000", DateDim[CurrentFiscalYear] = -1, REMOVEFILTERS(DateDim[Date].[Year])) RETURN CY - LYSolved865Views0likes4CommentsRead slicer values, retrieve corresponding table column values and use them to check existence
Hi all, I am trying to retrieve a column values based on the selected single/multiple slicer values and use those data to check their existence in the other table. Let me put this out clearly. There are two tables i.e., Calendar and Employee data. The calendar has the following columns i.e., fiscal year, fiscal year period, date. Adding the screenshot below. Calendar table: The Employee table has Name, Location, Joined Date. Employee table: The slicer in the Power BI dashboard is added with the 'Fiscal year period' column from 'Calendar' table. If the user selects a particular fiscal period or multiple fiscal periods, the corresponding dates from the Calendar table have to be read in a dax calculation and check the existence of those date values in the Joined date column in the table 'Employee'. For instance, if the user selects 2025 P3 and 2025 P4 from the slicer, then the corresponding dates from 3rd March to 4th May have to be read and check if any of those values exist in the column from other table i.e., in Joined date from Employee table. Could you please help me with a dax calculation/measures for this scenario? Any suggestions will be appreciated. Thanks! Microsoft EnterpriseDNASolved1.2KViews0likes6CommentsHelp Converting Tableau Date logic to PowerBI
I am trying to convert my date logic in tableau to powerBI: I have tried using AI but it does not seem to understand the end goal. Lets see if humans can still beat the AI. I have attached a workbook at the end of this post. I have tried multiple different dax calculations and adding new columns but to no luck. For reference I was able to get this logic to work in Tableau and here is a link to a workbook that shows the desired outcomes. Tableau Date Logic High Level overview of logic: A parameter allows the end user to select the date comparison they want and includes a custom where they can select their to and from dates to compare. Calculations use the parameter to slice the date calendar for their desired parameter choice. PowerBI issues: Problem 1: make sure AsofDate is using the correct DAX. As of Date should produce a date field. Problem 2: CurrentDatePeriod should only be true for select dates when selecting the date comparison fields. Should be a Boolean Problem 3: PriorDatePeriod does not recognize asofdate. Should be a Boolean Problem 4: DaysinRange Calculations are using incorrect DAX. Helps to calculate the custom fields the end user can choose for their own date comparisons. in the visuals you can see where I am validating the logic is working as desired. powerBI date logic Here is a breakdown of the Tableau logic. Parameters: ------------------ From: Data type Date, pulls from date calendar ----------------- ---------------- To: Data type Date, pulls from date calendar --------------- ---------------------- Date comparison ---------------------- Integer: Display as 1: Last Month vs Prior Month 2: Last Quarter vs Prior Quarter 3: Last Month YOY 4: Last Quarter YOY 5: Last Year vs Prior Year 6: MTD vs Prior MTD 7: QTD vs Prior QTD 8: YTD vs Prior YTD 9: Rolling 30 Days 10: Rolling 12 months 11: Custom 12: Last Week YOY Calculations: ----------------------- Partial Month Flag: DATETRUNC('month',[Date]) = DATETRUNC('month',{MAX([Date])}) ---------------------- ----------------------- Partial Quarter Flag: DATETRUNC('quarter',[Date]) = DATETRUNC('quarter',{MAX([Date] ----------------------- ----------------------- Partial Week Flag: DATETRUNC('week',[Date]) = DATETRUNC('week',{MAX([Date])}) ---------------------- ----------------------- partial year flag: DATETRUNC('year',[Date]) = DATETRUNC('year',{MAX([Date])}) ----------------------- ------------------------------ as of date ------------------------------ //MTD (6), QTD (7), YTD (8), Rolling 30 days (9) IF [Date Comparison] >= 6 AND [Date Comparison] <= 9 THEN {MAX([Date])} //Custom (12) ELSEIF [Date Comparison] = 12 THEN [To] ELSE {MAX( //Last Full vs. Prior Month (1) OR Last Full Month YoY (3) OR Rolling 12 Months (10) IF (( [Date Comparison] = 1 OR [Date Comparison] = 3 OR [Date Comparison] = 10 ) AND NOT [Partial Month Flag] ) //Last Full vs. Prior Quarter (2) OR Last Full Quarter YoY (4) OR (( [Date Comparison] = 2 OR [Date Comparison] = 4) AND NOT [Partial Quarter Flag] ) //Last Full vs. Prior Year (5) OR (( [Date Comparison] = 5) AND NOT [partial year flag] ) //Last Full week vs Prior Year (11) OR (( [Date Comparison] = 11) AND NOT [Partial Week Flag2] ) THEN [Date] END)} END ------------------- Current Date Period ------------------- IF [Date Comparison] = 1 OR [Date Comparison] = 3 OR [Date Comparison] = 6 THEN DATEDIFF('month',[Date],[As of Date]) = 0 ELSEIF [Date Comparison] = 2 OR [Date Comparison] = 4 OR [Date Comparison] = 7 THEN DATEDIFF('quarter',[Date],[As of Date]) = 0 ELSEIF [Date Comparison] = 5 OR [Date Comparison] = 8 THEN DATEDIFF('year',[Date],[As of Date]) = 0 ELSEIF [Date Comparison] = 9 THEN DATEDIFF('day',[Date],[As of Date]) < 30 AND [Date] <= [As of Date] ELSEIF [Date Comparison] = 10 THEN DATEDIFF('month',[Date],[As of Date]) < 12 AND [Date] <= [As of Date] ELSEIF [Date Comparison] = 11 THEN [From] <= [Date] AND [To] >= [Date] ELSEIF [Date Comparison] = 12 THEN DATEDIFF('week',[Date],[As of Date]) = 0 and [Date] <= [As of Date] END ----------------------------- Days in Range ----------------------------- DATEDIFF('day', {MIN( IF [Current Date Period] THEN [Date] END)}, {MAX( IF [Current Date Period] THEN [Date] END)})+1 ----------------------------- Days in range comparison ----------------------------- DATEDIFF('day', {MAX( IF [Prior Date Period] THEN [Date] END)}, {MAX( IF [Current Date Period] THEN [Date] END)}) ----------------------- prior date period ---------------------- IF [Date Comparison] = 1 THEN DATEDIFF('month',[Date], [As of Date]) = 1 ELSEIF [Date Comparison] = 2 THEN DATEDIFF('quarter',[Date], [As of Date]) = 1 ELSEIF [Date Comparison] = 3 THEN DATEDIFF('month',[Date], [As of Date]) = 12 ELSEIF [Date Comparison] = 4 THEN DATEDIFF('quarter',[Date],[As of Date]) = 4 ELSEIF [Date Comparison] = 5 THEN DATEDIFF('year',[Date],[As of Date]) = 1 ELSEIF [Date Comparison] = 6 THEN DATEDIFF('month',[Date] ,[As of Date]) = 1 AND [Date] <= DATEADD('month',-1,[As of Date]) ELSEIF [Date Comparison] = 7 THEN DATEDIFF('quarter',[Date],[As of Date]) = 1 AND [Date] <= DATEADD('quarter',-1,[As of Date]) ELSEIF [Date Comparison] = 8 THEN DATEDIFF('year',[Date],[As of Date]) = 1 AND [Date] <= DATEADD('year',-1,[As of Date]) ELSEIF [Date Comparison] = 9 THEN DATEDIFF('day',[Date],[As of Date]) >= 30 AND DATEDIFF('day',[Date],[As of Date]) < 60 ELSEIF [Date Comparison] = 10 THEN DATEDIFF('month',[Date],[As of Date]) >= 12 AND DATEDIFF('month',[Date],[As of Date]) < 24 ELSEIF [Date Comparison] = 11 then DATEDIFF('week',[Date],[As of Date]) = 52 ELSEIF [Date Comparison] = 12 THEN DATEDIFF('day',[Date],[As of Date]) >= [Days in Range] AND DATEDIFF('day',[Date],[As of Date]) < [Days in Range]*2 END PowerBI Date Logic Any help or feedback is greatly appreciated. Feel free to ping me with any questions. Thank you in advance. If anyone can help with this I will be truly convinced PowerBI can do what tableau can.Solved1.9KViews0likes8CommentsRemove duplicates and count from date column in new table
I have selected a dates column from another table and i now have them in a new column Select Col = SELECTCOLUMNS('Table') ,"Dates", 'Table'[Dates column]) I have then changed the format of the dates to MMM,Year so i have Jan24 Feb 24 Feb 24 Mar 24 etc I now want to 1 - remove duplicates 2- count the number of occurances for each month eg Jan 24 - 5 Feb 24 - 2 etc Do I do as above and count the occurances from the Dates Column from th eoriginal table or do i add another column to this table the same as Dates only without the duplciates and then count from the table containing the duplicates. so it woudl look like Dates, Date_excluding_duplicates, Count Any help really apprecaitedSolved959Views0likes5CommentsDisplay Two Different Dates from the same point on the X axis.
Hi, me again. I want to plot two lines that start from different dates in POWER BI. I have products that have a differents date of creation and i have to display the product since it launch on a line chart as X=0, so that my users get an understanding of how the respective product have fallen in delincuency product launch. This is what i currently have: This just a running total of the percentage of clients that fell into delincuency, but notice that both of these linnes start at different dates, they should star at point 0, measured by the numbers of weeks since the product launched. Sometihng like: Imagine that in the X axis we have numbers from 0 to whatever and that both start from 0, i just picked the two closest that i had. I'll leave a mockup file attached, product of previous help: https://drive.google.com/file/d/1uems6jCzxqkJHNdtcnXxxHxBo222XPB1/view?usp=drive_linkSolved995Views0likes3CommentsHelp with measure - count incidents between given dates
Hi I need some help with a measure please! I have two tables as below. Table 1 shows a list of contracts that can renew leading to multiple rows for the same contract but with start/end dates to differentiate them. Table 2 has a list of incidents that have occurred on those contracts by date. How can I create a measure to show the incidents by contract linked to the incident date to give the required results in the bottom example? At the moment the two tables are only connected by contract number (I'm wondering if they need to be linked on the dates too?). Thanks in advance for any help. Table 1 Table 2 Contract Number Contract Start Contract End Contract Number Incident Date 1 01/01/2021 31/12/2021 1 13/01/2021 1 01/01/2022 31/12/2022 1 15/05/2021 2 01/01/2023 31/12/2023 1 20/05/2022 3 01/07/2021 30/09/2021 3 15/11/2021 3 01/10/2021 31/12/2021 3 01/01/2022 31/03/2022 Required Result Contract Number Contract Start Contract End Incidents 1 01/01/2021 31/12/2021 2 1 01/01/2022 31/12/2022 1 2 01/01/2023 31/12/2023 0 3 01/07/2021 30/09/2021 0 3 01/10/2021 31/12/2021 1 3 01/01/2022 31/03/2022 0Solved793Views0likes2CommentsSum for most recent date available
I have a table that records sales by date. I need to be able to display the total sales for each date and also display the prior date's total. What is a measure in dax that I can use to sum based on whatever the next most recent date is? I tried doing a RANKX column on the record dates, which works correctly in providing a numbered rankings for date, then used the below: Prior Date Sales = CALCULATE(SUM(RecordDate[Sales], RecordDate[RankNo] = RecordDate[RankNo]-1) However when I use this measure in a table with the date and total sales, the Prior Date Sales is blank. Is there anything I'm missing with this measure? Sample of data and the result I'm trying to accomplish: Table: Record Date Sales 5/13/2024 100 5/9/2024 200 5/9/2024 200 5/2/2024 300 5/2/2024 300 4/28/2024 400 4/28/2024 100 Totals: Record Date Total Sales Prior Date Sales 5/13/2024 100 400 5/9/2024 400 600 5/2/2024 600 500 4/28/2024 5001.4KViews0likes6CommentsFind the max date that is less than a specific date, considering a grouping factor (Power Query)
Hi, I have the following table in Power Query: I need to add a column that follows the following logic: if Date1 = Date3 then Date1, otherwise find the maximum date in Date3 that is less than the Date1 of each row, considering the group ID. Is it possible to do this in Power Query? ThanksSolved823Views0likes1CommentPrevious Month Calculation to Forecast
Hi all, I have the below data: Month Headcount Hires Other Increase Other Decrease February 400 0 0 March 20 10 20 April 5 10 0 May 10 0 0 Problem statement: I need to create a calculation that sums up the headcount, hires, increases and decreases for future months. I want March to take February's headcount and add March's respective Hires, Other Increases and minus Other Decreases. For example March would be 400 + 20 +10 -20 = 410 April would then take March's value (410) and perform the same calculation: 410 +5 +10 - 0 = 425 May would then take Aprils number and so on... I am having trouble trying to get each month to take the calculated vale of the month before. Please help and thank you in advance.2.3KViews0likes14Comments