Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello folks,
I am again struggling with some Dax issues.
I have two measures:
MEASURE 1:
VAR _Test= CALCULATE(CONCATENATEX('01 Chassis Cab',
if(SEARCH(FIRSTNONBLANK('01 Chassis Cab'[Feature code],1),SELECTEDVALUE('MBOM Extract Code Matrix'[Variant Formula]),,0)<>0,'01 Chassis Cab'[Feature code],"")),'01 Chassis Cab'[Behavior]="include")
RETURN
if(_Test <> BLANK(), "yes","no")
MEASURE 2:
VAR _Test= CALCULATE(CONCATENATEX('03 MY25 FC',
if(SEARCH(FIRSTNONBLANK('03 MY25 FC'[Feature code],1),SELECTEDVALUE('MBOM Extract Code Matrix'[Variant Formula]),,0)<>0,'03 MY25 FC'[Feature code],"")),'03 MY25 FC'[Behavior]="include")
RETURN
if(_Test <> BLANK(), "yes","no")
BOTH measures work fine when draged into a table visual.
When I go to DAX Query viewer, ONLY measure 2 is always bringing "no" as result.
I will try your proposal and come back to provide some feedback. Thank you
It seems like the issue might be related to the context in which the DAX query is being evaluated and how the relationships between tables are affecting the results. The behavior you're describing, where one measure works in a table visual but not in a DAX query, can be caused by differences in row context and filter context.
The SELECTEDVALUE function is highly dependent on the context it's used in. It relies on a single value being selected in the column within the current context. In a table visual, the row context is established by the rows in the table, and SELECTEDVALUE can work as expected. However, in a DAX query, the context might be different, leading to unexpected results.
Without having the full data model and understanding the relationships between tables, it's challenging to pinpoint the exact issue. However, I can suggest a few general tips and potential solutions:
Check Relationships: Make sure that there are proper relationships established between the tables involved in your DAX measures. Relationships play a crucial role in determining the context in which calculations are performed.
Use RELATED: Instead of relying on SELECTEDVALUE, you might consider using the RELATED function to traverse relationships and retrieve values from related tables.
Evaluate Measure Independently: Try evaluating each measure independently in the DAX query to see if they produce the expected results. This can help isolate the issue to a specific measure or context.
Row Context and Row Context Transition: Be aware of how row context and row context transition work in DAX. Understand the difference between row context and filter context, as well as the impact of row context transition functions like CALCULATE.
Here's a modified version of your DAX query to demonstrate the use of RELATED:
EVALUATE
SUMMARIZE(
'MBOM Extract Code Matrix',
'MBOM Extract Code Matrix'[Index],
'MBOM Extract Code Matrix'[Item ID],
'MBOM Extract Code Matrix'[Variant Formula],
"MY242 Excluded", [MY24.2 excluded feature],
"MY242 included", [MY24.2 included feature],
"MY242 specific", [MY24.2 Specific line],
"Chassis Cab excluded", [CC excluded feature],
"Chassis Cab included", [CC included feature],
"Chassis Cab specific", [CC Specific line],
"MY25 excluded", [MY25 excluded feature],
"MY25 included", [MY25 included feature],
"MY25 specific", [MY25 Specific Line],
"MY26 excluded", [MY26 excluded feature],
"MY26 included", [MY26 included feature],
"MY26 specific", [MY26 Specific Line],
"MY27 excluded", [MY27 excluded feature],
"MY27 included", [MY27 included feature],
"MY27 specific", [MY27 Specific Line],
"project", RELATED('YourProjectTable'[Master Project BL]) -- Use RELATED to traverse relationships
)
Replace 'YourProjectTable' with the actual name of the table that contains the 'Master Project BL' column.
By explicitly using RELATED, you are instructing DAX to follow the relationships between tables to retrieve the desired values.
If the issue persists, further investigation into the data model and relationships may be required.
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
7 | |
6 |