powerbi
98 TopicsPercent of Customers Returned After 90 Days
Hello, I'm trying to create a DAX formula to find the % of customers that returned 90 days after their first purchase. I've spent several hours trying to create and recreate the formula but have not been able to replicate the numbers in the screenshot (for the 3rd or 4th column): I know there are other posts online about this, but none of the formulas have worked for me or any manipulations. I have a Sales table with CustomerKey and OrderDate. I have a Customer table with CustomerKey and DateFirstPurchase. I've spent many hours working on this and various formulas but this is the one I'm working with now: Purchase within 90days(%) = VAR Customerlist = VALUES( Sales[CustomerKey] ) VAR Returndate = 90 VAR CountCustomers = COUNTROWS( FILTER( Customerlist, CALCULATE( COUNTROWS (Sales), FILTER( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] > ( MIN ( Sales[OrderDate] ) ) && 'Calendar'[Date] < MIN ( Sales[OrderDate]) + Returndate ) ) >0 ) ) Return DIVIDE(CountCustomers,[Customers]) Any help or insight is greatly appreciated.Solved2.4KViews0likes12CommentsStrict Top 10 by ABS() measure even with duplicate values
Power BI — Top N visual filter returning more than 10 rows due to ties (already tried rank (dense/skip created column for rank & summary table) Problem Statement I have a Line and Stacked Column chart in Power BI where: X-axis: Country Column Y-axis: Measure = Sleeping Difference = Sleeping SFDC This Week – Sleeping SFDC Last Week Line Y-axis: Another measure (not relevant to this issue) I want to filter to Top 10 countries by absolute Sleeping Difference. DAX Definitions Sleeping Difference = [Sleeping SFDC This Week] - [Sleeping SFDC Last Week] ABS Sleeping Difference = ABS([Sleeping Difference]) Sleeping SFDC This Week Sleeping SFDC This Week = CALCULATE( COUNT('Sleeping IB+Lost'[Equipment #]), 'Sleeping IB+Lost'[Week] = MAX('Sleeping IB+Lost'[Week]) ) Sleeping SFDC Last Week Sleeping SFDC Last Week = VAR RankedWeeks = ADDCOLUMNS( VALUES('Sleeping IB+Lost'[Week]), "WeekRank", RANKX(VALUES('Sleeping IB+Lost'[Week]), 'Sleeping IB+Lost'[Week], , DESC) ) VAR SecondMaxWeek = MAXX(FILTER(RankedWeeks, [WeekRank] = 2), 'Sleeping IB+Lost'[Week]) RETURN CALCULATE( COUNT('Sleeping IB+Lost'[Equipment #]), 'Sleeping IB+Lost'[Week] = SecondMaxWeek ) The Issue When I use the Top N filter in the Visual Filter pane: Top N = 10 by [ABS Sleeping Difference] If multiple countries have the same value (ties), Power BI includes all tied countries, so I get more than 10 countries in the visual — sometimes 17, 20, or even 30. What I Have Already Tried (to avoid duplicate answers) Top N visual filter — Standard approach (Top N by ABS Sleeping Difference) ✅ Works for most cases, ❌ still returns >10 when there are ties. Summary table with TOPN() Top10Countries_SleepingDiff = TOPN( 10, SUMMARIZE( 'YourTable', 'YourTable'[Country], "AbsDiff", ABS([Sleeping Difference]) ), [AbsDiff], DESC ) Used TREATAS and visual filters to show only countries in this table. ❌ Still shows >10 due to ties. RANKX approach CountryRank = RANKX( ALL('YourTable'[Country]), ABS([Sleeping Difference]), , DESC, Dense ) Tried both Dense and Skip ranking methods. Applied FILTER(CountryRank <= 10) in visuals. ❌ Still includes extra countries when ties occur at rank 10. Manual visual filter using a rank column Created a calculated column with rank. Set visual filter to Rank <= 10. ❌ Did not solve the problem when multiple rows per country exist or when ties occur at the cut-off. What I Need Help With I’m looking for a robust approach to: Show exactly 10 countries in the visual. Break ties deterministically (for example, by adding a secondary sort like Country Name). Avoid including all tied countries if they push the total above 10. Sample Data (for testing) Country Week Sleeping SFDC This Week Sleeping SFDC Last Week USA 32 12 8 Canada 32 20 16 Mexico 32 5 8 UK 32 9 2 Germany 32 15 20 France 32 11 15 Italy 32 3 1 Spain 32 25 21 Japan 32 14 10 China 32 18 19 India 32 4 0 Brazil 32 17 15 Australia 32 8 8 Argentina 32 6 3 South Africa 32 7 1 Russia 32 5 2 Netherlands 32 9 4 Request If you know a DAX or modelling technique that will: Always return exactly 10 countries, Handle both positive and negative differences using ABS, Break ties consistently without exceeding 10, …please share your approach.Solved1.4KViews0likes4CommentsDAX Expression to remove an existing filter and apply new one
Hello, I have a Date filter in the report where I'm selecting current month. I have a requirement where I will have to calculate a certain measure with a new filter value i.e. remove the current filter and reapply a new filter. I'm restricted to using a single filter in the report which is set to current month. I'm using the following DAX expression currently where my current filter is set to "January" and I'm trying to retrieve data for "December": TechnicalEmpHeadcountProjection = CALCULATE([Technical Employee Headcount *], FILTER(ALL('Budgeting v_IncomeStatement'[PeriodFormatted].[Month]), 'Budgeting v_IncomeStatement'[PeriodFormatted].[Month]= "December")) The above DAX expression doesn't seem to work. [PeriodFormatted] is my Date column. I'm also attaching a screenshot. Kindly assist me with the DAX. Regards, RBSolved33KViews0likes4CommentsSumming up of manhours based on slicer range selection corresponding to filtered jobs
In power bi, I need a measure for dax code where when user selects date range from a slicer (calender table), jobs (only the instances where it lies in the selected calender date range) and corresponding manhours (only for the selected calender date range) from my table Bi_ alloceffort_data gets displayed where the REVDATE in same table falls between the user selected range. I tried the follwomg codes: 1. Selected_Manhours := VAR SelectedMinDate = MIN('Calendar'[Date]) VAR SelectedMaxDate = MAX('Calendar'[Date]) RETURN CALCULATE( SUM(Bi_alloceffort_data[Manhours]), Bi_alloceffort_data[REVDATE] >= SelectedMinDate && Bi_alloceffort_data[REVDATE] <= SelectedMaxDate ) 2. Selected_Manhours := VAR SelectedMinDate = MIN('Calendar'[Date]) VAR SelectedMaxDate = MAX('Calendar'[Date]) RETURN SUMX( FILTER( Bi_alloceffort_data, Bi_alloceffort_data[REVDATE] >= SelectedMinDate && Bi_alloceffort_data[REVDATE] <= SelectedMaxDate ), Bi_alloceffort_data[Manhours] ) 3. Selected_Manhours := VAR SelectedMinDate = MIN('Calendar'[Date]) VAR SelectedMaxDate = MAX('Calendar'[Date]) RETURN CALCULATE( SUM(Bi_alloceffort_data[Manhours]), KEEPFILTERS( Bi_alloceffort_data[REVDATE] >= SelectedMinDate && Bi_alloceffort_data[REVDATE] <= SelectedMaxDate )) But all the solutions are selecting the job based on slcier filter and then summing all the manhours (even ehen they are outside the slicer range) for the all job instances. I need manhours only for the instance where jobs and manhours are within the selected slicer range. Pls helpSolved1.2KViews0likes7CommentsDate +1 day to get data to show in different month
Hi! I'm trying to add 1 day to a date because the data (for example) shows in January but I would like it to show in February. The case is: a contract ends at 1 date and the new contract starts at a new date. Problem is: when filtering to the data I would like to show, I can only get the ending date. In most cases this is at the end of the month, for example 31-01-2025, so in the report it obviously shows up in January. I would like it to show in February, that's why I would like to add 1 day. The date column is a integer '20250131'. So I need to convert it to date with DAX + I need filters to get the specific data out. This is one of the things that I tried: Contracts = CALCULATE( DISTINCTCOUNT('FACT_Contract'[%ContractKey]), 'FACT_Contract'[VALUE] = 1.00, 'FACT_Contract'[Subject] IN { "Days" }, DATE( DIVIDE(SELECTEDVALUE('FACT_Contract'[DATE]), 10000), DIVIDE(MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 10000), 100), MOD(SELECTEDVALUE('FACT_Contract'[DATE]), 100) ) ) This is the error that I'm getting: "The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column." Converting the date in a single measure works, filtering the data to get what I need works in a single measure. But combining both doesn't work. I'm not sure if it's even possible to do what I want. If anyone has an idea, please let me know. Thanks in advance!Solved471Views0likes2CommentsIssues with Matching Dynamic and Static Emissions Calculations in Power BI
Hello Power BI Community, I am facing a challenge in my Power BI report where the dynamic calculations for a measure, scope-based emissions, do not align with average emissions under certain conditions, specifically when no scopes or all scopes are selected. I expect these conditions to yield identical results in two different line charts, but they do not. Issue Description: Line Chart Discrepancy: When no scopes or all scopes are selected, the line chart for "Dynamic Scope Emissions" should mirror the chart for "Avg Asset GHG Emissions (CO2e per $’m)," but the results differ. Table Totals Mismatch: The total values in my data table for "Dynamic Scopes Emissions" do not match those for "Avg Emissions per Revenue (per Sm)", indicating a potential issue in how totals are computed. Current Setup: 1. I use a custom table for scope selections called "Scope Options", defined as follows: Scope Options = DATATABLE( "Scope", STRING, "Selected", BOOLEAN, { {"Scope 1", FALSE}, {"Scope 2", FALSE}, {"Scope 3", FALSE} } ) 2. Dynamic Scopes Emissions Formula: This formula is designed to dynamically sum emissions based on selected scopes and calculate average emissions per million USD of revenue. The formula and its components are intended to adjust based on the slicer's scope selection: Dynamic Scopes Emissions = VAR IsScope1 = CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 1") VAR IsScope2 = CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 2") VAR IsScope3 = CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 3") VAR ScopeSum = SUM(ESG_Assets_Data_Pivot[scope1]) * IsScope1 + SUM(ESG_Assets_Data_Pivot[scope2]) * IsScope2 + SUM(ESG_Assets_Data_Pivot[scope3]) * IsScope3 VAR TotalRevenue = SUM(ESG_Assets_Data_Pivot[revenue_usd]) VAR Default = NOT(IsScope1 || IsScope2 || IsScope3) // True if no scopes are selected RETURN DIVIDE( IF( Default, SUMX( VALUES(ESG_Assets_Data_Pivot[company_name]), SUM(ESG_Assets_Data_Pivot[scope1]) + SUM(ESG_Assets_Data_Pivot[scope2]) + SUM(ESG_Assets_Data_Pivot[scope3]) ), ScopeSum ), TotalRevenue / 1000000, BLANK() ) 3. Additional Measure for Context: "Average Emissions Per Revenue (per mil)" is used to provide a high-level view of emissions efficiency per revenue, calculated as: Average Emissions Per Revenue (per mil) = AVERAGEX( VALUES(ESG_Assets_Data_Pivot[company_name]), DIVIDE( [Total Emissions], SUM(ESG_Assets_Data_Pivot[revenue_usd]) / 1000000, 0 ) ) Where "Total Emissions" is calculated as follows, summing emissions from all three scopes if any are greater than 0.1: Total Emissions = IF( SUM(ESG_Assets_Data_Pivot[scope1]) + SUM(ESG_Assets_Data_Pivot[scope2]) + SUM(ESG_Assets_Data_Pivot[scope3]) > 0.1, SUM(ESG_Assets_Data_Pivot[scope1]) + SUM(ESG_Assets_Data_Pivot[scope2]) + SUM(ESG_Assets_Data_Pivot[scope3]), BLANK() ) Asset Avg Emissions per Revenue (using total emissions) Dynamic Scope Emissions scope 1 scope 2 scope 3 revenue Total Emissions A 0.22 0.22 0 0 12.97 $58,286,725.86 12.97 B 292.95 292.95 122.22 129.13 31769.37 $109,302,981.64 32,020.72 C 307.78 307.78 1206 1128 116905 $387,421,494.72 119,239 Total 90.85 272.56 1328.22 1257.13 148687.34 $555,011,202.23 151,272.69 Objective: The "Dynamic Scope Emissions" should accurately reflect the combination of selected scopes and match the "Avg Asset GHG Emissions" when either all scopes or no scopes are selected. What I've Tried: Verified slicers are correctly linked. Checked individual asset data which appears accurate. Reassessed formulas for any logical or contextual errors. Request for Assistance: Could anyone help identify why these discrepancies occur or suggest modifications to ensure the DAX formula works as intended? Insights into correcting these values would be immensely appreciated. Thank you for your time and help!Solved943Views1like4Comments% of Total Calculation with Sub-Categories
Feel like I should know this but I am having an issue and need some help. I want to calculate the % from Total in a report and have it calculate for both the main, and sub-level categories I have in the rows. I know why my current formula isnt working but need some help on how to fix. I want it to calculate from the total for both sub and main categories. If someone can lead me in the right direction it would be greatly appreciated. Maybe I am not even using the best formula to do this. Thanks. Info below. First formula will calculate the percentage correctly for the main category, but the sub displays 100% for every value. % of Total = (CALCULATE(sum([Issues Reported]))/(calculate(sum([Issues Reported]),ALL(TABLE1[MAIN CATEGORY])))) This one obviously does the opposite, calculating the % from the sub and leaving main with 100% % of Total = (CALCULATE(sum([Issues Reported]))/(calculate(sum([Issues Reported]),ALL(TABLE1[MINOR CATEGORY]))))Solved5.7KViews0likes10CommentsRemoving a slicer interaction while still using the slicer value
In my report, a user will select a date using a date between slicer and we're only using the minimum date selected. This date can be any day of the week. I want to show the sales numbers for the entirety of that week. For example, if a user selects a Wednesday, I want to show the values for Sunday through Saturday of that week. I have tried several remedies, but it seems like I either show the days leading up to the selected day or the days after the selected day-- I have not been able to see the entire week at once. One attempt of a calculation was CALCULATE(sum(*redacted sales table info*),ALL('vw_D_Date'[date_value]),FILTER(*redacted sales table*,[MinimumSelectedDate])) where MinimumSelectedDate = FIRSTDATE('vw_D_Date'[date_value]) Any suggestions on how to solve this?Solved710Views0likes2Commentscreate measures with filters
Hello, I need to create measures using some filter to be able to make some card visuals. here is what I did: I have my date base with all years information, so for making the "sales per year" i made to measures: 2025 = SUM(...) and filtered in 2025 poryjected sales. 2024 = CALCULATE([Facturación],SAMEPERIODLASTYEAR('Calendar'[Date])) - I created a measure of get the sales of previous year. than I made a measure to get the difference between both 2024 adn 2025 sales. WHAT I SHOULD DO: I made to charts one "increasing of sales" detailed all the "clientes" that has a positive result and I was using the filter panel. and another of "lost sales" with all the negative results. I need to add some cards to summarize the totals. I have one showing the total of sales in 2025 I need a card showing the total of increaisng sales that is "2,066,314" and a card showing the total of lost sales that is "-919,865" thank you!Solved760Views0likes2Comments