if
69 TopicsDAX Issue
Hi, I have the following DAX (credit https://addendanalytics.com/blog/calculate-working-hours-in-power-bi) which creates a time from hours and minutes between 06:00 and 23:59 and I want to make a small change: var Hours_List = SELECTCOLUMNS(GENERATESERIES((6), (23)), “Hour”, [Value]) var Minutes_List = SELECTCOLUMNS(GENERATESERIES((0), (59)), “Minute”, [Value]) var two_years_ago_start = DATE(YEAR(NOW())-2,1,1) //DATE(2018,1,1) var one_year_later_end = DATE(YEAR(NOW())+1,12,31) var Dates_List = CALENDAR(two_years_ago_start,one_year_later_end) var HoursandMinutes = ADDCOLUMNS( CROSSJOIN(Hours_List, Minutes_List), “Time”, TIME([Hour], [Minute], 00), “Validity”, IF([Hour]<6 || [Hour]>23,”Non working”,”Working”) ) I would like the list to stop at 23:45 but only for hour 23. I want the window to be 06:00 to 23:45 but still count the last 15 minutes in all other hours. My instinct is to use an IF on the ADDCOLUMNS function used in setting the variable HoursandMinutes but I'm not sure exactly what it would look like as I am used to managing these changes in SQL where I would say: WHERE NOT (Hours_List = 23 AND Minutes_List > 44) Any help would be wonderful Thanks in advance MattSolved3.5KViews0likes3CommentsIf statement between 2 tables - reproducing sql
Hello, my sql statement is: -- This query calculates the applied discount rate for SKUs based on their retail prices and effective prices. WITH OnDemandPrices AS ( SELECT DISTINCT PartNumber, PayGPrice FROM vnomic_Daily.Fct_EA_AmortizedCosts WHERE PricingModel = 'OnDemand' ), RetailPricing AS ( SELECT a.PricingModel, a.BenefitName, a.ReservationName, a.PayGPrice, a.MeterCategory, CASE WHEN a.PricingModel = 'Reservation' THEN MAX(od.PayGPrice) ELSE MAX(a.PayGPrice) END as RetailPrice, MAX(a.EffectivePrice) as EffectivePrice, SUM(a.CostInBillingCurrency) AS SumCostInBillingCurrency FROM vnomic_Daily.Fct_EA_AmortizedCosts a LEFT JOIN OnDemandPrices od ON a.PartNumber = od.PartNumber WHERE a.Date >= '2025-04-01' AND a.Date < '2025-05-01' GROUP BY a.PricingModel, a.BenefitName, a.ReservationName, a.MeterCategory, a.PayGPrice, ) So I have the issue with setting DetailPrice variable using DAX. What i would like to do after is to add this detailprice to matrix. So we have 2 tables here so somehow i need to join tables before applying dax. What can be your approach ? How you would resolve it? Best, JacekSolved580Views0likes3CommentsProblemns with IF logic VAR
Hello everyone, who are you guys doing? I am preparing a comparative dashboard about two dev platforms and encountered a logical problem. Basically, I have to apply a conditional logic within DAX which I thought would be easy. Every time I filter a value (visual filter) on the page, it will perform a calculation by taking fixed values and multiplying them by the value selected in the filter. So, hypothetically speaking, if my Project A does not have available data, I have to perform this calculation for it: (Fixed Jenkins Median / Fixed Azure Median) * Filtered project median value. The measure was implemented as follows: if the calculation needs total values from both platforms, and when I filter by project, I created a VAR for the total of Azure and Jenkins but FIXED, so I can derive the values by division. VAR for acronyms and VAR totals were also created to perform the other calculations. Has anyone done something similar and can help me? Here is the DAX with logic: // CONDITIONAL VAR JenkinsResult = IF( ISFILTERED(dGeneral[Acronym 2]), IF( ISBLANK(FilteredJenkinsMedian), (FixedJenkinsTotalMedian / FixedAzureTotalMedian) * AzureAcronymMedian ), TotalJenkinsMedian ) VAR Platform = SELECTEDVALUE(dGeneral[Platform]) // SWITCH VAR FinalResult = SWITCH( Platform, "Azure", TotalAzureMedian, "Jenkins", JenkinsResult ) RETURN FinalResult820Views0likes2CommentsIF Function & Filter Help
The Goal is to have one column that generates "SDR Gen" is the SRD Name and AE Name are not blank, and generate "Self Gen" if the SDR name is blank and the AE Name is not blank. Here are the two formulas I have tried, any tips? SDR Gen = (IF(Opportunity[SDR Name]<> BLANK() && Opportunity[AE Name]<>BLANK(), "SDR Gen"), IF(Opportunity[SDR Name]= BLANK() & Opportunity[AE Name]<> BLANK(), "Self Gen", BLANK())) SDR Gen = (IF(Opportunity[SDR Name]<> BLANK(), "SDR Gen", "Self Gen"), FILTER(Opportunity, Opportunity[AE Name]<> BLANK())) Any suggestions on how to make this work would be greatly appreciated.Solved550Views0likes1CommentMultiple IF followed by NOT (syntax error?)
Hey team, Recieved a lot of really useful information from this community already! Thank you! I'm essentially converting GUID's from Salesforce back to staff names for a visual: Staff = IF('DataTable'[Staff GUID]="005Mn1234567", "Joe Bloggs", //the above converts the GUID to "Joe Bloggs" IF('DataTable'[Staff GUID]="005Mn1234568", "Jane Doe", //the above converts the GUID to "Jane Doe" The issue I'm having - is currently I only know a portion of the GUID's, and I'm hoping for those I don't, in the calculated table it will just show the GUID. In my mind it went something like: NOT('DataTable'[Staff GUID]=("005Mn1234567", 005Mn1234568"), 'DataTable'[Staff GUID]) ie- if the GUID isn't specified as a staff name, just display the GUID. However getting all sorts of sytax errors and #error. Anyone have any direction or advice on this one? I'm extremely green with DAX.Solved880Views0likes3CommentsCreate Custom Column using an IF Statement based on two columns
Hi All, I have a dataset, that contains numerous columns of data, but main ones are: Columns: Branch Status Despatch Date Requested Date Promised Date I want to calculate the difference in days between the Despatch Date & the advised date.. So the logic needs to be like below. If Branch="York" & Status = "Out" (so i need both these to be satasified before it determins the true/false. If True = Despatch Date.Days - Requested Date.Days If False = Despatch Date.Days - Promised Date.Days Any assistance would be apprecaited.Solved1.2KViews0likes4CommentsA lot of IF and OR statements - Making it run slow
Hi all, I am having some issues with the performance of some of my reports, due to some measures running slow. Some base info: I am connected to an Azure Blob Storage, collecting data in CSV format. I do some cleaning using Power Query The measure(s) in question: Newsletter Permissions For my company there are some different criteria a recipient have to have, in order to be have a newsletter permission, and they are: If any of the following are true: IF( [ComplaintCheck]=1 || [LastEmailCheck]=1 || (It's more than 365 days since you last got an email) [MalformedCheck]=1 || [ValidEmailCheck]=1 || [UnsubscribedCheck]=1 ) OR if ALL of the following are true or BLANK: IF( Created more than 365 days ago First use of app is more than 365 days ago Your last app use is more than 1000 days ago Your last interaction is more than 1000 days ago Your last web use is more than 1000 days ago Your permission is set within the last 365 days ) For all of the above I have made a seperate measure looking like this: IF( OR( NOT(SUM('agillic-targetgroup'[Days Since First Use])<365), SUM('agillic-targetgroup'[Days Since First Use])=BLANK() ) ,1 ,0 ) I have used Power Query to created columns that calculate how many days it has been since the different dates. I can provide a sample set if needed. I hope some of you can help.788Views0likes4CommentsTrying to make custom flag for in market and out of market time bwteen 2 tables
I am trying to make a simple comparison for time entries that looks as if the service location of a time entry is the same as the employee home branch, the time entry lives in its own table with the service location, and has a many to one relationship with cross directional filtering with the employee table which houses that persons home location. The dax I have currently is as follows: Out of Market Flag = IF(EXACT(Time_Entry[Service Location], 'Member'[Employee Location]), "In Market", "Out of Market") I have tried a few different variations but I cant seem to get the function to want to take the service location and employee location as inputs. I am sure what I am missing is simple but for the life of me I cant seem to find an example of this online to use for comparison. Thanks in advance!Solved911Views0likes6CommentsMeasure: Summarize by Group and add and IF statement
How to sum/summarize, by group and an IF: Data As Is Product Name Transaction ID Jurisdiction Type Gross Amount P0001 123123 STATE 125.00 P0001 123123 COUNTY 125.00 P0001 123123 CITY 125.00 P0001 123123 STC 125.00 P0001 123123 STATE 125.00 P0001 123123 CITY 125.00 P0001 123123 STATE 25.00 P0002 456456 STATE 10.00 P0002 456456 CITY 10.00 P0002 456456 STATE 10.01 P0003 456456 STATE 5.00 P0004 789789 STATE 1.50 P0004 789789 STATE 1.50 Summary of what it should be Product Name Transaction ID Product Name Total Gross Amount P0001 123123 P0001 275.00 P0002 456456 Multiple/P0002/P0003 25.01 P0004 789789 P0004 3.00 Formula 1: Gross Sales = SUMX( KEEPFILTERS( VALUES( 'Transactions'[Product_Name] ) ), CALCULATE( SUMX( SUMMARIZE('Transactions', 'Transactions'[Transaction ID], 'Transactions'[Gross Amount] ), [Gross Amount]) ) ) This gives me Transaction 123123 for 150.00, but should be Transaction 123123 as 275.00 It returns the sum of non-duplicate values. However, I would like for it to return the sum of values, even if it is a duplicate value, IF the Jurisdiction Type is "STATE" is present multiple times. The Jurisdiction Type as State represents a separate, product/purchase. For example, IF I go to the store, and I buy two avocados in one bag, and the cashier rings it up, and then scan more products, and then I have two more avodacos in the same purchase, the receipt will have 2 avocados for 3.00, then Cereal for 5.00, Soup for 2.00, and then 2 MORE avocados for 3.00. However, I want it to combine the avocados into 4 avocados for 6.00. So I want to continue to group by the Product name and transaction ID, but add and IF the jurisdiction type is "STATE" then also sum/add, even if it is a duplicate value. I also used the formula below but returns the same values as Formula 2. FORMULA 2: Gross Sales 1 = SUMX( FILTER( 'Transactions', [Jurisdiction Type] = "STATE"), CALCULATE( SUMX( SUMMARIZE('Transactions', 'Transactions'[Transaction ID], 'Transactions'[Gross Amount]), [Gross Amount]) ) )Solved550Views0likes1CommentIdentify records where the first created date meets a condition from a second variable
i have CRM data with where i need to create a new column which will index a '1' for all ID's where the first invoice issued 'CreatedDate' was paid ('State' = 2). So with the below example only row 2 is deemed as first invoice paid. Data context - Each unique 'ID' will have a unique 'ContractID' but many 'InvoiceID'. I've tried to nest CALCULATE(MIN(Table[CreatedDate) with RETURN but couldnt get it to work. Row ID ContractID InvoiceID CreatedDate ModifiedDate State 1 b6910000-00000-ed11-00000-0001000 CONTRACT-0100 BAGG31322 20/04/2023 20/04/2023 0 2 BAG312683 21/02/2023 23/05/2023 2 3 BAG314743 09/05/2023 09/05/2023 0 4 BAG315613 09/03/2023 09/03/2023 0Solved1.2KViews0likes6Comments