The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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,
Leonardo
Solved! Go to Solution.
Hello,
in DAX query view, you do not have the filter you apply in the visualization, so SELECTEDVALUE returns a blank.
If you want to see the value in the query view, you need to inject the filter like instalead of calling the measure [Data-base] in row 6 or 8 (depending on the images you show) you call
CALCULATE ( [Data-base], Data_Base_Lista[Data-base] = DATE ( 2025,7,17 ) )
YOu can also let Power BI do this automatically if you open the performance analyzer, start recording and refresh that visual. You can then copy the query and paste it in the query view. You will see there that Power BI injects the selected value form the visual into the query, typically with a TREATAS table call, then used as a FILTER (DSO_FILTER or something like this)
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
DAX Query view is not aware of your filter context, you have to tell it all the filters you want to use, ideally via TREATAS.
Hello,
in DAX query view, you do not have the filter you apply in the visualization, so SELECTEDVALUE returns a blank.
If you want to see the value in the query view, you need to inject the filter like instalead of calling the measure [Data-base] in row 6 or 8 (depending on the images you show) you call
CALCULATE ( [Data-base], Data_Base_Lista[Data-base] = DATE ( 2025,7,17 ) )
YOu can also let Power BI do this automatically if you open the performance analyzer, start recording and refresh that visual. You can then copy the query and paste it in the query view. You will see there that Power BI injects the selected value form the visual into the query, typically with a TREATAS table call, then used as a FILTER (DSO_FILTER or something like this)
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
Understood. I initially thought the DAX query editor would pick up whatever slicer choice I have on the report, but I realized that can't be done since there could be several unsynced slicers tied to the same field and placed on several different reports under the same .pbi file, which would make it impossible for the DAX query editor to choose which slicer to grab the value from.
Thanks for taking the time to clarify that!
User | Count |
---|---|
28 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
36 | |
14 | |
12 | |
8 | |
7 |