"selectedvalue"
11 TopicsSELECTEDVALUE measure from slicer keeps returning blank value when used on another measure
So I have this simple dropdown slicer which is a list containing only a couple of dates, which in turn comes from a single-column table currently with NO relationship to either the date and the fact tables (CalData and Contas_a_Pagar respectively) in the semantic model: Then I created the following measure that picks up whatever choice I made on the aforementioned slicer: Data-base = SELECTEDVALUE(Data_Base_Lista[Data-base]) And when I drop this measure on a card visual it works just fine, so the measure is in fact picking up my date slicer choice: PROBLEM: However, when I define and evaluate the same measure on DAX query view, it returns BLANK: ↓↓↓↓↓↓↓ The problem is that I'm using this measure as a base date to calculate other measures, for instance to calculate the total of invoices whose due dates are on or after the selected base-date, and this measure is instead returning the grand total of all invoices (it should be $1,535,135.96 not $5,475,597.89 as shown below), and the reason is because the measure 'Date-base' is BLANK, so this other measure ends up picking up all invoices since their due dates are all on or after a blank date: Conversely, when I setup another measure that is supposed to calculate the total of invoices whose due dates are before the selected date, this measure also returns BLANK, instead of the correct total amount of $3,940,461.93, since this measure can't find any due date that is prior to a blank base-date: QUESTION: I know this is a basic stupid issue, but I just can't seem to figure out a way to fix this, even after having watched several videos about the SELECTEDVALUE function. What am I doing wrong here? Thanks, LeonardoSolved6.7KViews0likes3CommentsHow Can I Calculate the Years Service of each employee
I have Table EmploymentDetails I will mention the importent columns EmploymentStartDate , PersonnalNumber I want to calculate the Years of Service and the number of months in Years of Service as You shown above I tired to create column to calculate Years of Service " Years of Service = VAR Years = DATEDIFF(EmploymentDetails[EmploymentStartDate],TODAY(), YEAR) VAR Months = DATEDIFF(EmploymentDetails[EmploymentStartDate],TODAY() , MONTH) - (Years * 12) VAR result = Years + (Months / 12) RETURN ROUND(result, 1) " this Measure worked correctly it has calculated the Years of Service from EmploymentStartDate of each employee untily today but I want to calculate the Years of Service depend on the slicer the employee's years of service are calculated based on the date I tried to create this Column " YearsOfServices = VAR Years = DATEDIFF(EmploymentDetails[EmploymentStartDate], SELECTEDVALUE(EmploymentDetails[EmploymentStartDate]), YEAR) VAR Months = DATEDIFF(EmploymentDetails[EmploymentStartDate], SELECTEDVALUE(EmploymentDetails[EmploymentStartDate]), MONTH) - (Years * 12) VAR result = Years + (Months / 12) RETURN ROUND(result, 1) " but there is not result could anyone help me to create a column and Measure please ? thank in advanceSolved2.2KViews0likes7CommentsShow last N months based on FiscalYearMonth slicer selection without calendar/date table
My requirement Ex-1 When the user select a value say 202501 from slicer "FiscalYearPeriodCd" which is a text data type. The table below should display last 13 months . Ie from 202401 to 202501. ---Last 13 months Ex-2 When the user selects "202411" , the table below should display SalesUSD from 202311 to 202411 .---Last 13 months. .Unfortunately i have a calendar table but the calendar table and fact table are related using someother key and not a datekey as per the business requirement and hence i cannot change it.Also in my date table , i have the date repeated twice.One is for US and another for Non US due to fiscal calculation.Hence i cannot use datesinperiod , dateadd or other date related functions.Hence the only option is to use FiscalYearPeriodCd. Raw data below SalesUSD FiscalYearPeriodCd 534132759.5 202201 1557801979 202202 695221259.1 202203 813135024.7 202204 832097591.8 202205 755491149.2 202206 848978369.6 202207 831567295.5 202208 907314200.6 202209 822103615.4 202210 674213875.8 202211 -2879970782 202212 859510773.8 202301 908174754.8 202302 856401757.6 202303 864263784 202304 880142006.9 202305 861088774.2 202306 -2353615032 202307 968984985.4 202308 -1857687494 202309 868514132.3 202310 -66961618.2 202311 1317854317 202312 1060522633 202401 1011795775 202402 829441979.7 202403 1100402094 202404 1064195484 202405 1138271467 202406 1898901.5 202407 754629775 202408 130722055.9 202409 1437834704 202410 912161100.4 202411 167628959.9 202412 486353211.6 202501 98759203.23 202502 Expected output for Ex 1 slicerselection = 202501 MgmtRateUSD FiscalYearPeriodCd 1060522633 202401 1011795775 202402 829441979.7 202403 1100402094 202404 1064195484 202405 1138271467 202406 1898901.5 202407 754629775 202408 130722055.9 202409 1437834704 202410 912161100.4 202411 167628959.9 202412 486353211.6 202501 expected output for ex 2 - slicerselection = 202411 MgmtRateUSD FiscalYearPeriodCd -66961618.2 202311 1317854317 202312 1060522633 202401 1011795775 202402 829441979.7 202403 1100402094 202404 1064195484 202405 1138271467 202406 1898901.5 202407 754629775 202408 130722055.9 202409 1437834704 202410 912161100.4 202411 Thank you so much in advance.Solved744Views0likes3CommentsYTD filter based on the selected month
Hello, I'm trying to create a dynamic time filter based on the selected month (Always one month selected in the report): MTD: Selected month YTD: Janv - to selected month (No cumulation !) FY: Janv - Dec First I tried with calculation group but I always get cumulated YTD result. Now I try with a DAX table but I can't link the selected month in the DAX table... Model: DAX Filter table: MonthFilter = Var _SelectedMonth= max(SelectedMonth[SelectedMonth]) Var _MonthFilter = UNION( ADDCOLUMNS( SELECTCOLUMNS(GENERATESERIES ( _SelectedMonth,_SelectedMonth,1 ) ,"Mois",INT([Value])) ,"MonthFilter","MTD" ,"Order",1) ,ADDCOLUMNS( SELECTCOLUMNS(GENERATESERIES ( 1,_SelectedMonth,1 ) ,"Mois",INT([Value])) ,"MonthFilter","YTD" ,"Order",2) ,ADDCOLUMNS( SELECTCOLUMNS(GENERATESERIES ( 1, 12 ,1 ) ,"Mois",INT([Value])) ,"MonthFilter","Full Year" ,"Order",3) ) Return _MonthFilter Result: Thanks for your help 🙂1.2KViews0likes7CommentsDax Maxx function, but ignoring the Filter, and Slicers
I have a calculation that calculates the MAX value of a Measure: I used the Removefiltes it works but if you filter the actual visual the dax does not work anymore, kind of like a double negative: My visual is a gauge, that is filter on the side panel on a specific Vertical. This is my code: Max Outsourced Market Size = CALCULATE( MAXX( VALUES( Verticals[V1] ), CALCULATE( [Market Size Supply Chain] - [Market Size Outsourced], ALLEXCEPT(Verticals, Verticals[V1]) ) ), ALLEXCEPT(Verticals, Verticals[V1]) ) I think it should also ignore the SELECTEDVALUE. Please help anyone.Solved2.3KViews0likes8CommentsMultiple Select option
Hi I couldn't quite find the answer to my question online so I decided to drop the question on the forums myself. I have two tables that have no relationship Client (Distinct) Table: Client Client 1 Client 2 Client 3 Client Information Table: Client Sale Item name Client 1 50 Pencil Client 1 60 Sharpner Client 2 70 Calculator Client 3 75 Pencil Client 3 80 Sharpner I created a DAX code (that works) which highlights a selected client one colour and their competitors a different colour which is: Client Distiction = var selectedClient = SELECTEDVALUE('Client Distinct Table'[Client]) return SWITCH( SELECTEDVALUE(Client Information Table[Client])=selectedClient, TRUE, "#006D9E" , "#A6E2EF" ) This code works if you use two different filters and put the client distinct table 'client' coloumn in the first filter, and the client infromation table 'client' column in the second filter. If you select one client in the first filter, then it will highlight that client if selected in the second filter. However, if you select multiple clients in the first filter it will not longer colour the selected clients in the chart. Is there a way to fix this? So, if you select client 1 and client 2, both these clients will be highlighted in a scatter graph/bar chart/line chart, and the rest of the clients will be highlighted another colour. Thank you for your help. Look forward to the responses. I am a beginner so please explain it as simply as possible 🙂Solved1.3KViews0likes6CommentsFilter a table based on multiple selected values
Hi all, I am currently using a switch() statement within a measure to filter a table appropriately depending on a selection like so: _Orders_BY_superhero_preference = VAR SelectedOption = SELECTEDVALUE(SuperHeroes[name]) VAR code = SELECTEDVALUE(SuperHeroes[code]) VAR all_codes = SELECTCOLUMNS(SuperHeroes,"code",[code]) RETURN CALCULATE([_Orders],FILTER(OrderTable, OrderTable[matched] = "Y" && OrderTable[order_number] IN all_codes && SWITCH( SelectedOption, "Batman", RELATED('CustomerAttributes'[Fav_superHero]) = "Batman" && CONTAINSSTRING(OrderTable[order_number],code), "Spiderman", RELATED('CustomerAttributes'[Fav_superHero]) = "Spiderman" && CONTAINSSTRING(OrderTable[order_number],code), "Superman", RELATED('CustomerAttributes'[Fav_superHero]) = "Superman" && CONTAINSSTRING(OrderTable[order_number],code) ))) Where the measure [_Orders] is basically a DISTINCTCOUNT of order ids, and the rows included in the aggregation are determined by which superhero name is selected. This works with a single option eg: name = Batman. However, is there a way that I can modify this so that it works with multiple selected options? In other words if Both Batman and Spiderman are selected, the OrderTable is filtered such that it contains rows where the 'matched' column = "Y", the order_number value exists in the SuperHeroes code table, and only rows where the related values in the customerAttributes table are Batman or Spiderman are included in the aggregation? I've tried replacing SELECTEDVALUE with VALUES, but having some trouble with figuring out how to account for multiple selections within the switch logic.637Views0likes2Commentsswitch() and SelectedValue for multiple filter choices
I am currently trying to build a measure that has three variables. To return the values, I used Switch() to allow for the selection of filters. When I use distinctive values, the measure works perfectly. But I get the alternate result back when I choose two filters. Is there any DAX expression I can use to create combinations of filters and decide what the response needs to be? My measure currently VAR A = Calculate (DISTINCTCOUNT(TableA), Dim_A[SalesType]="ABC") VAR B = Calculate (DISTINCTCOUNT(TableA), Dim_A[SalesType]="DEF") VAR C = Calculate (DISTINCTCOUNT(TableA), Dim_A[SalesType]="GHI") SWITCH ( SELECTEDVALUE ( Dim_A[SalesType] ), "ABC", A, "DEF", B, "GHI", C, A+B+C) Ideally, I would like to be able to create combinations where I say If chosen values are "ABC"&"DEF", give me A+B, "DEF"&"GHI", give me B+C, etc.Solved7.3KViews0likes4CommentsHow to swich column based on the calue of SELECTEDVALUE?
Hi all; I am stacked in getting the value of SELECTEDVALUE in calculated column. The DAX formula I am using is returning blank while the same formula works and returns value when used with a measure. The DAX formula I am using looks like following: Legend = SWITCH( SELECTEDVALUE(Metrics[Metrics Fields]), "'MyMeasures'[% 0-5 months]",[% 0-5 months category], "'MyMeasures'[% 6-23 months]",[% 6-23 months category] ) thanks1.3KViews0likes5CommentsHow to use DAX formula SELECTEDVALUE with Field Parameters
Dear Power BI community, I would like to ask for your help as I am trying to use DAX formula SELECTEDVALUE based on field parameters, however it is not doable based on the following error message: IF user selects between two value the (Amount USD & Amount LCL) the calculation should be changing based on that: DAX formula : Field Parameter: Visualization selection for Amount USD & Amount LCL: Would it be possible for someone to help how to change the DAX formula SELECTEDVALUE part to make it work? Thank you for your advice in advance. Wishing you a wonderful date. AdamSolved5.8KViews0likes7Comments