help required
100 TopicsDefine Percentage format in DAX
Coverage% = If(Divide(SUM('IHFD vwCoverage'[IHFD]),SUM('IHFD vwCoverage'[HIPE]))>1,100,FORMAT(Divide(SUM('IHFD vwCoverage'[IHFD]),SUM('IHFD vwCoverage'[HIPE])),"0.0%")) For Percentages greater than 100% I set to 100% , but I want to display 100% (No decimal place 0%) in this instance and when percentage is less than 100 .ie. 98.7 I want to illustrate as 0.0% I tried setting the measure to General format via the modelling menu and I tried setting the default format to Percentage with 0 decimal places in the via the modelling menu, use dax as above to set to 1 decemial place Can this be done in dax, have two different formats based on derived valueSolved86KViews1like2CommentsFiltering Table Based On Measure Value
Hello, I'm running into some issues while trying to parameterize a query in Power BI Report Builder. For the parameters, I need to be able to select multiple values so I can't use conventional filter expressions like Filter(<Table>,[Field]="LookupValue"). I've found how to get this to work for columns that exist in the raw data but am having trouble with values calculated from measures. Here's the relevant code that I'm attempting to use: VAR StatusCount = PATHLENGTH ( @ProjStatus) VAR StatusNumberTable = GENERATESERIES ( 1, StatusCount, 1 ) VAR StatusTable = GENERATE ( StatusNumberTable, VAR StatusCurrentKey = [Value] RETURN ROW ( "Key", PATHITEM ( @ProjStatus,StatusCurrentKey ) ) ) VAR GetKeyStatusColumn = SELECTCOLUMNS ( StatusTable, "Key", [Key] ) VAR __DS0Core = SUMMARIZECOLUMNS( 'Projects'[Project Name], "WorstStatus", 'Meta_EngStatusSummary'[WorstStatus] ) EVALUATE CALCULATETABLE( __DS0Core,INTERSECT( SELECTCOLUMNS ( __DS0Core, "Key", [WorstStatus] ) , GetKeyStatusColumn)) [WorstStatus] is a measure with possible values "Green", "Yellow", and "Red" FWIW. The first 4 variables are used to convert the input string ("Green|Yellow") to a single-column table (GetKeyStatusColumn) which I'm trying to use to filter __DS0Core. The issue that I'm running into is that CALCULATETABLE is not filtering __DS0Core based on the filter applied. I'm trying to mimic the approach used here: https://community.powerbi.com/t5/Desktop/Filter-table-based-on-another-table/m-p/519101/highlight/false#M242748 Looking at the values of GetKeyStatusColumn and the SELECTCOLUMNS that I'm using to pull the WorstStatus column, both tables appear correctly/as expected on their own. I believe the issue is that the SELECTCOLUMNS breaks the relationship between it and __DS0Core, but I may be wrong. When trying to use [WorstStatus] directly without SELECTCOLUMNS, an error is thrown that it is not a table. Any suggestions on how to try to correct this or another approach to test would be greatly appreciated. Thanks ahead of time.Solved11KViews0likes2CommentsLast Non zero Value based on max date
Hi All I am trying to get the last charged amount to an id which im running into the issue of getting zeros where the last entry is a zero. My current formula only looks at the max value based on the latest date, the part im struggling with is if the returned value is zero i would like the last non zero amount. Last Rent Charged = CALCULATE(MAX(RentUnitCharge[ChargeAmount]),FILTER(RentUnitCharge,RentUnitCharge[StartDate] = MAX(RentUnitCharge[StartDate]))) example data of the issue, UnitId ChargeAmount StartDate 78268 84.25 01/06/2006 00:42 78268 87.7 02/04/2007 00:00 78268 91.56 07/04/2008 00:00 78268 96.6 06/04/2009 00:00 78268 94.99 05/04/2010 00:00 78268 97.83 04/04/2011 00:00 78268 101.8 02/04/2012 00:00 78268 104.77 01/04/2013 00:00 78268 108.64 07/04/2014 00:00 78268 108.64 14/07/2014 00:00 78268 0 18/05/2015 17:42 Any help would be great. Kind RegardsSolved7.9KViews0likes10CommentsDAX in building Rolling 4 Week Average
Hi, I need help in building 4 week rolling average for "Net Change in Price and Cost" with below sample data Change in Price, Change in Cost and Net Change in Price and Cost are all 3 measures. Net Change in Price and Cost = Change in Price - Change in Cost I do have separate date table and the above data shows weekly data and my report has Invoice Date as Filter. I need to calculate rolling 4 week average, here the tweak is that for first week start date 12/07 rolling average should be same while for next 12/14 it should (-4.80% + 0.18%)/2 = -2.31% for 12/21 it should be (-4.80% + 0.18% - 0.04%)/3 = -1.55% for 12/28 it should be (-4.80% + 0.18% - 0.04% -0.65%)/4 = -1.33% for 01/04 it should be (0.18% - 0.04% -0.65% +1.03%)/4 = 0.13% as shown below I have created below DAX but its not working as expected Net Change in Price and Cost 4 Wk Rolling Avg = var start_day = MIN('Date'[Week Start Date])-21 var end_day = MAX('Date'[Week Start Date]) return CALCULATE([Net Change in Price and Cost], DATESBETWEEN('Date'[Week Start Date],start_day,end_day), REMOVEFILTERS('Date'[Week Start Date]))/CALCULATE(DISTINCTCOUNT('Date'[Week Start Date]),DATESBETWEEN('Date'[Week Start Date],start_day,end_day),REMOVEFILTERS('Date'[Week Start Date])) Can someone help me on this??Solved7.1KViews0likes5CommentsPrevious Dynamic Period DAX Calculation
I've followed the guide on https://radacad.com/previous-dynamic-period-dax-calculation for creating a dynamic previous period. So if I select a date range for the current period of; 01/06/2019 to 01/06/2019 the previous period is 31/05/2019 to 31/05/2019 01/06/2019 to 02/06/2019 the previous period is 30/05/2019 to 31/05/2019 01/06/2019 to 07/06/2019 the previous period is 25/05/2019 to 31/05/2019 01/06/2019 to 30/06/2019 the previous period is 02/05/2019 to 31/05/2019 01/04/2019 to 30/06/2019 the previous period is 31/12/2019 to 31/03/2019 However the StartOfPreviousPeriod measure is not ideal for me. For example, selecting a date range of 01/06/2019 to 30/06/2019 for the current period means that the StartOfPreviousPeriod is 02/05/2019, as in the example above. StartOfPreviousPeriod = FIRSTDATE ( PREVIOUSDAY ( DATEADD ( CalendarCombined[Date], -1 * [DaysInCurrentPeriod], DAY ) ) ) However what I would like to do is have the date show as 01/05/2019 but I cannot figure out a way without breaking the dynamic elements of it. For clarity, using the examples supplied above if I select a date range for the current period of; 01/06/2019 to 01/06/2019 the previous period should be 31/05/2019 to 31/05/2019 01/06/2019 to 02/06/2019 the previous period should be 30/05/2019 to 31/05/2019 01/06/2019 to 07/06/2019 the previous period should be 25/05/2019 to 31/05/2019 01/06/2019 to 30/06/2019 the previous period should be 01/05/2019 to 31/05/2019 01/04/2019 to 30/06/2019 the previous period should be 01/01/2019 to 31/03/2019 Any assistance would be greatly appreciated.Solved6.9KViews0likes2CommentsShow 30 days data in visual before the date selected in date slicer
Hi All, I have a date slicer and a line chart. My requirement is on selecting a date in date slicer , 30 days of data should be displayed in line chart ahead of date selected in date slicer. If someone came across same scenario. Please suggest the solution. Regards VaishaliSolved6.5KViews0likes5CommentsYTD Flag using DAX
Hi I have a requirement to add a flag in my report. Flag has two values YTD Flag and Full Year. When YTD Flag is selected, it will show the values in the table in terms of Jan 1 of the respective year to the current date, while Full Year flag shows the data from 1st jan to 31st dec of respective year. I have my data from year 2020, 2021 and 2022 and want to display the revenue for each year on different columns in table. To display each year revenue on different columns I am using below dax 2020 Revenue = CALCULATE( SUM(data[Revenue]), FILTER( data, YEAR(data[Invoice Date]) = 2020 ) ) Same for other years by changing year in above dax. Need help in creating Flag meachanism. Appreciate your help!Solved5KViews0likes11CommentsCalculate Last Transaction Records
Hi, Within Power BI, I have a below table and I want to create another column which calculates Last Margin % for every records. If the customer A buys product A12 then for its Last Margin % is null and if same customer (i.e. A) buys same product (i.e. A12) then its Margin % will 30%. So my result table will be as below. I want to write DAX for this. Can some one help me on this?Solved4.8KViews0likes7CommentsRemove Duplicates Per Group (keep first) measure help
Hi All Is it possible to create a measure in PBI that remove duplicate values per group, and keeps the first occurrence of the value? Perhaps not a measure but maybe a new table, I'm unsure of how to work around this. For context, the database I'm working with has a funky treatment of some data that has a function back-end but doesn't make sense when trying to visualise user behaviour. Currently, the data looks like: USER ENTRY ID ENTRY STATUS TIME SUBMITTED (HH:mm:ss) userA 1 unicorn fail 10:23:10 userA 2 forest pass 10:30:49 userA 1 unicorn fail 10:30:49 userB 1 unicorn fail 13:40:22 userB 1 fairy pass 13:43:59 I want to clean it so it looks like: USER ENTRY ID ENTRY STATUS TIME SUBMITTED (HH:mm:ss) userA 1 unicorn fail 10:23:10 userA 2 forest pass 10:30:49 userB 1 unicorn fail 13:40:22 userB 1 fairy pass 13:43:59 ... ... ... ... ... Note the row I want to remove has duplicated ENTRY from the first instance for userA and duplicated TIME SUBMITTED from the first instance for userA Also, the ENTRY ID cannot be used. Any pointers would be greatly appreciated 🙂Solved4.8KViews0likes5CommentsHelp in Cumulative Total
Hi I am facing issues with Cumulative Total. Below are the DAX I am using for cumulative total. I have below table Week Start Date | Margin | Margin Last Year Week | Difference in Margin I have to take Cumulative of Difference in Margin Margin is measure Margin Last Year Week is measure calculated as Margin Last Year Week = CALCULATE( [Margin], FILTER( ALL('Date'), 'Date'[Week Rank] = MAX('Date'[Week Rank])-52 ) ) Difference in Margin is a measure which is calculated as Difference in Margin = CALCULATE( ([Margin] - [Margin Last Year Week]), FILTER('Date','Date'[Year] = 2022) ) Cumulative Total DAX Margin Diff Cumulative = CALCULATE( [Difference in Margin], FILTER( ALL('Date'), 'Date'[Date] <= MAX('Date'[Date]) ) ) We have neagative values from March as we don't have data from March 2022 (difference is calculated by taking difference of previous year week from current year week in focus.) so Feb cumulative value should be 4997451 + 2398854 = 7396305 ( which is coming as 7494045 which is wrong ) I want to display this Cumulative value in column chart and also I want that it should display till Feb without using any invoice filter as we have data from Jan 2021 to Feb 2022 and data is populated on weekly basis so this graph will gradually increases weekly. Any help will be appreciated. Thanks!Solved4KViews0likes24Comments