interesting links
24 TopicsAccrued Vacation formula in power BI
Hi, I am working on tracking PTOs in power Bi. I want to create a DAX query on the basis of below parameters 1.) 0 – 2 years = 10 days per year 2 – 10 years = 15 days per year 10+ = 20 days per year 2) If anyone joins on or before 15th of a particular month, then he/she gets leaves for that particular month else from next month onwards. 3) Also, if any employee hits milestone in the current year, e.g. if one of the employee who joined on 9-aug-2022 is completing 2 yr milestone oln 9-aug-2024, ideally his accrual should be =((10/12)*7) + ((15/12)*4)=10.83 . I have tried using below formula but somehow it is not giving me desired output. Let me know if anyone has any inputs or suggestions... Accrued Vacation = VAR StartDate = SELECTEDVALUE('Employee Roster'[Start Date]) VAR CurrentDate = TODAY() VAR CurrentYear = YEAR(CurrentDate) VAR StartYear = YEAR(StartDate) VAR StartMonth = MONTH(StartDate) VAR CurrentMonth = MONTH(CurrentDate) VAR StartDay = DAY(StartDate) VAR Tenure = DATEDIFF(StartDate, CurrentDate, YEAR) VAR AnniversaryDate = DATE(YEAR(StartDate) + Tenure, MONTH(StartDate), DAY(StartDate)) -- Determine Monthly Accrual Rates VAR MonthlyAccrualBefore = SWITCH( TRUE(), Tenure < 2, 10 / 12, Tenure < 10, 15 / 12, 20 / 12 ) VAR MonthlyAccrualAfter = SWITCH( TRUE(), Tenure + 1 < 2, 10 / 12, Tenure + 1 < 10, 15 / 12, 20 / 12 ) -- Determine Effective Date for New Joins VAR EffectiveDate = IF(StartYear = CurrentYear, IF(StartDay <= 15, DATE(CurrentYear, StartMonth, 1), EOMONTH(StartDate, 0) + 1), DATE(CurrentYear, 1, 1) ) -- Calculate Months Before and After Anniversary VAR MonthsBeforeAnniversary = IF( AnniversaryDate <= CurrentDate, DATEDIFF(EffectiveDate, AnniversaryDate, MONTH), DATEDIFF(EffectiveDate, CurrentDate, MONTH) ) VAR MonthsAfterAnniversary = IF( AnniversaryDate <= CurrentDate, DATEDIFF(AnniversaryDate, CurrentDate, MONTH), 0 ) -- Calculate Total Accrued Vacation VAR AccruedVacation = IF( DAY(AnniversaryDate) <= 15, (MonthlyAccrualBefore * MonthsBeforeAnniversary) + (MonthlyAccrualAfter * (MonthsAfterAnniversary + 1)), (MonthlyAccrualBefore * (MonthsBeforeAnniversary + 1)) + (MonthlyAccrualAfter * MonthsAfterAnniversary) ) -- Adjust for the specific case where the anniversary date is after the 15th of the month VAR FinalAccruedVacation = IF( DAY(AnniversaryDate) > 15, (MonthlyAccrualBefore * MonthsBeforeAnniversary) + (MonthlyAccrualAfter * MonthsAfterAnniversary), AccruedVacation ) -- Ensure correct calculation for milestones within the current year VAR CorrectedAccruedVacation = IF( Tenure = 1 || Tenure = 9, (MonthlyAccrualBefore * (MonthsBeforeAnniversary + 1)) + (MonthlyAccrualAfter * MonthsAfterAnniversary), FinalAccruedVacation ) RETURN ROUND(CorrectedAccruedVacation, 2)Solved1.6KViews0likes6CommentsHow to get distinct cumulative Sum of Day wise
Hi Community Member, Please help me to achieve some desired result using power bi dax. Please see the attached details explanation and output we need. See below calculation that we need to convert into power bi dax to achieve output mentioned right side below.Solved728Views0likes2CommentsCalcualting repeat cusotmers for each month and then totaling it up for all months
Hi, I have a requirement where for each month starting six months ago until current selected month, it should calculate the repeat customers that purchased in any previous months and then total up the repeat customers for all six months. For example There are ten customers, A, B, C, D, E, F, G, H, I, J. Customer A, B, C, D and E purchased a product in December. In January, we have D, E, F cusotmers so we have two repeat customers. In Feb, A, H and I purchased. Since A, purchased previously (Dec), we have 1 repeat cusotmer in Feb. In March, we have B, E, H and J so we have three repeat customers and so on. We calculate this until current month. Eventually, we total up the repeat for all months. How can I calcualte this using DAX?Solved784Views0likes2Commentsokay icon
I have the following table. And I have the following matrix look The "Planned" measure is: CALCULATE( SUM( fac_NFs_SFs[valor_liquido_nf] ), USERELATIONSHIP( dim_Calendario[Data], fac_NFs_SFs[data_previsao_recebimento] ) ) The "Achieved" measure is: CALCULATE( SUM( fac_NFs_SFs[valor_liquido_nf] ), USERELATIONSHIP( dim_Calendario[Data], fac_NFs_SFs[data_recebimento] ) ) The months "Mar", "Mai" and "Jun" = dim_calendario[mês] I need that when I have a receipt date, all the month contexts have the Okay icon, ignoring the month of the column context. I can't do this because the forecast sum uses the forecast column and the received sum uses the received date column. What do I do?1.1KViews0likes3CommentsAlarm Log Page
Hi @v-yohua-msft , This question is next to "Alarm Log, Start Time & End Time in Power BI Visual" which you have already answered. Can you help me to get a single instance rather than all the records of Low Temp and same Clear Time for all. Alarm Log Table should contain: Start Time: 09-02-2024 11:29 End Time: 09-02-2024 11:36 Date Time Asset State Number Alarm Category 09-02-2024 10:57 A 2 Clear 09-02-2024 11:29 A 101 Low Temp 09-02-2024 11:30 A 101 Low Temp 09-02-2024 11:31 A 101 Low Temp 09-02-2024 11:32 A 101 Low Temp 09-02-2024 11:34 A 101 Low Temp 09-02-2024 11:35 A 101 Low Temp 09-02-2024 11:36 A 2 Clear 09-02-2024 11:37 A 2 Clear 09-02-2024 11:38 A 2 Clear You have provided below DAX to create a table: Alarm Log = ADDCOLUMNS( FILTER( 'Table', 'Table'[State Number] <> 1 && 'Table'[State Number] <> 2 && 'Table'[State Number] <> 3 ), "Start Time", 'Table'[Date Time], "End Time", CALCULATE( MIN('Table'[Date Time]), FILTER( ALL('Table'), 'Table'[Asset] = EARLIER('Table'[Asset]) && 'Table'[Date Time] > EARLIER('Table'[Date Time]) && ('Table'[State Number] = 1 || 'Table'[State Number] = 2 || 'Table'[State Number] = 3) ) ) ) Thank You in Advance.Solved5.6KViews2likes4CommentsCalcualted column from two distinct tables
Hello , I am creating a calcualted column which is basically dividing one value by another. Both the columns are present in two different tables and they are connected via bridge tabes as nothing is common between them. So below is a picture of my data model. The calculation isnt coming up correctly. What may be the possible reasons for it ? Calcualtion - The One column is from cross channel table and other column is from benchmark table. Both are basically just getting divided.391Views0likes1CommentExclude user with condition from the chart
Hi everyone, I have a problem that I hope you can help me with. I have user data tracked by events. I want the chart to filter out users who have at least one event_type=1 within a specified time period. However, when I add this measure to a chart with the Y-axis as Month and Year, it doesn't work. Here is the measure I wrote: actions_by_user_not_having_event1 = var cte = filter (SUMMARIZE( fact_event, fact_event[user_id], "MinEventType", CALCULATE(MIN(fact_event[event_type]), ALLSELECTED('Date'[Date])) , "events", COUNTROWS(fact_event) ), [MinEventType] > 1) return SUMX(cte, [events]) Thank you guysSolved1.9KViews0likes8CommentsNext Year Budget/Forecast in Current FYear
Hi There, I am stuck and running out of ideas for a use case I recently received. Writing down the Use case below: We have a Forecast table that locks the forecast based on the fiscal year i.e for FY2023 and FY2024 they upload the forecast scenarios in the following manner: F23Budget F23E1 F23E2 F23E3 F24Budget So the catch here is that for every forecast entry they will have the mentioned Fiscal year forecast and also the forecast they imagined that they would have for next fiscal year. For better understanding look at the below table. Scenario TimeID F23E1 01-07-2022 F23E1 01-08-2022 F23E1 01-09-2022 F23E1 01-10-2022 F23E1 01-11-2022 F23E1 01-12-2022 F23E1 01-01-2023 F23E1 01-02-2023 F23E1 01-03-2023 F23E1 01-04-2023 F23E1 01-05-2023 F23E1 01-06-2023 F23E1 01-07-2023 F23E1 01-08-2023 F23E1 01-09-2023 F23E1 01-10-2023 F23E1 01-11-2023 F23E1 01-12-2023 F23E1 01-01-2024 F23E1 01-02-2024 F23E1 01-03-2024 F23E1 01-04-2024 F23E1 01-05-2024 F23E1 01-06-2024 in Order to seperate the original F23E1 and the Temp F23E1 we seperated the scenario into 2 diff scenarios again as below: Scenario TimeID Scenario ID F23E1 01-07-2022 Budget E1 F23E1 01-08-2022 Budget E1 F23E1 01-09-2022 Budget E1 F23E1 01-10-2022 Budget E1 F23E1 01-11-2022 Budget E1 F23E1 01-12-2022 Budget E1 F23E1 01-01-2023 Budget E1 F23E1 01-02-2023 Budget E1 F23E1 01-03-2023 Budget E1 F23E1 01-04-2023 Budget E1 F23E1 01-05-2023 Budget E1 F23E1 01-06-2023 Budget E1 F23E1 01-07-2023 Next Fiscal Budget E1 F23E1 01-08-2023 Next Fiscal Budget E1 F23E1 01-09-2023 Next Fiscal Budget E1 F23E1 01-10-2023 Next Fiscal Budget E1 F23E1 01-11-2023 Next Fiscal Budget E1 F23E1 01-12-2023 Next Fiscal Budget E1 F23E1 01-01-2024 Next Fiscal Budget E1 F23E1 01-02-2024 Next Fiscal Budget E1 F23E1 01-03-2024 Next Fiscal Budget E1 F23E1 01-04-2024 Next Fiscal Budget E1 F23E1 01-05-2024 Next Fiscal Budget E1 F23E1 01-06-2024 Next Fiscal Budget E1 Now when we calculate the values based on the scenarios as the above fact table has a relationship with Calendar table, When the calculated scenarios are placed in the matrix and the fiscal year is used in the atrix they both are seperated into 2 different Fiscal years as below: But the catch here is that, The user doesn't want to see the 2 scenarios falling into different fiscal years, as the next fiscal E1 FY is actually coming from F23E1 they would like to see both in the same fiscal year as below: But the calculations or the dax that I'm using here are not the right one's or not meeting my expectations. for the above visual to work I have used Dateadd and ignored the Scenario ID and calculated it for Next Year but whenever I switch between fiscal years it is showing me the data for FY2022 as well. Does anyone know any other way this could work. Any suggestions or any links that can help me find a solution works. Thanks in Advance. amitchandak lbendlin Greg_Deckler technolog parry2k Ritaf1983 Idrissshatila Ahmedx429Views0likes0CommentsPower BI Stacked chart - Time vs Category visual
Hi @ConnieMaldonado @BA_Pete @kewaynes @v-alq-msft , I have a quick query in regard to how to use a stacked bar chart in Power BI which would show the category vs. Time. I was able to create one in Excel using time series But trying to figure out the same in Power BI Visual. It would be really helpful if someone could share their thoughts on the same. Please feel free to reach out to me on any additional information. Excel Graph: I colored the cells of Layover to White (So it shows as a gap), Blue highlighted are all Travel times. Raw data Sample: ID Number Start Time Travel Layover Travel Layover Travel Layover Travel Layover Travel Layover Travel 3 05:25:00 00:23:00 00:07:00 00:31:00 00:14:00 00:30:00 00:15:00 00:42:00 00:18:00 00:40:00 00:20:00 00:36:00 4 05:25:00 00:23:00 00:07:00 00:25:00 00:05:00 00:32:00 00:13:00 00:40:00 00:20:00 00:45:00 00:15:00 00:37:00 I really appreciate the help! Looking forward to the tips/solution. Regards Vishnu313Views0likes0Commentshow to calculate lost customer distinct count on month level using dax measure in power pivot?
Hello everyone, I hope you're all doing well. I'm currently working on a project and could use some guidance regarding a DAX measure. I'm trying to calculate distinct counts for different types of customers on a monthly basis, and I'm encountering a few challenges. Specifically, I'm aiming to determine the following metrics using DAX measures: Lost Customer Distinct Count: The count of customers who were active in the previous month but haven't made any transactions in the current month. New Customer Distinct Count: The count of customers who are making their first transaction in the current month. Repeat Customer Distinct Count: The count of customers who have made transactions in both the current month and the previous month. The database has been loaded into Power Query, and I've successfully established connections in Power Pivot. Additionally, I'm hoping to enhance this analysis by segmenting the results based on categories and brands, if possible. If any of you have experience with DAX measures and are willing to lend a helping hand, I would greatly appreciate it. Your expertise could make a significant difference in advancing this project. Thank you in advance for your support. Looking forward to your insights! Best regards, Santosh Sample database table for reference. date customer id 01 January 2022 cust-001 02 January 2022 cust-002 03 January 2022 cust-003 01 January 2022 cust-001 01 February 2022 cust-001 02 February 2022 cust-002 03 February 2022 cust-004 02 February 2022 cust-002 01 March 2022 cust-001 01 March 2022 cust-002 01 March 2022 cust-005 01 March 2022 cust-002684Views0likes3Comments