Hi,
I am trying to do a DAX calculation with filtered data using the following DAX:
Solved! Go to Solution.
Hi again @cwozniak03
College_Totals_No_Loans = VAR CurrentStudentNumber = 'All Grant Amounts'[student_number] VAR CurrentCollegeID = 'All Grant Amounts'[college_id] RETURN CALCULATE ( SUM ( 'All Grant Amounts'[grant_amount] ), 'All Grant Amounts'[student_number] = CurrentStudentNumber, 'All Grant Amounts'[college_id] IN { CurrentCollegeID, 0 }, 'funding_types'[funding_type_id] <> 3,
// Clear all filters on the table,
// since CALCULATE adds all values from current row to filter context
// Filters specified above will still apply
ALL ( 'All Grand Amounts' ) )
The above expression might not quite do what you want (I made a few guesses about the logic), but I think this is the sort of structure you should use.
Could you describe roughly in words what the calculation should be returning, perhaps with some sample data?
Regards,
Owen
Hi Chris,
At a glance, it appears to be a misplaced bracket causing the error.
Try changing
&& RELATED('funding_types'[funding_type_id] <> 3)
to
&& RELATED('funding_types'[funding_type_id]) <> 3
Please post back if that doesn't fix it
Regards,
Owen
Ha, thanks that was dumb.
It did fix the fully qualified error, but gives me a new error stating that the column either doesnt exist or douesnt have a relationship to any table in the current context even though it does: PS I also tried grants[funding_type_id] as I just realized when posting this image that I dont need the ID from the funding types table.
Hi again @cwozniak03
College_Totals_No_Loans = VAR CurrentStudentNumber = 'All Grant Amounts'[student_number] VAR CurrentCollegeID = 'All Grant Amounts'[college_id] RETURN CALCULATE ( SUM ( 'All Grant Amounts'[grant_amount] ), 'All Grant Amounts'[student_number] = CurrentStudentNumber, 'All Grant Amounts'[college_id] IN { CurrentCollegeID, 0 }, 'funding_types'[funding_type_id] <> 3,
// Clear all filters on the table,
// since CALCULATE adds all values from current row to filter context
// Filters specified above will still apply
ALL ( 'All Grand Amounts' ) )
The above expression might not quite do what you want (I made a few guesses about the logic), but I think this is the sort of structure you should use.
Could you describe roughly in words what the calculation should be returning, perhaps with some sample data?
Regards,
Owen
Owen,
Thank you so much for this, I am just starting out with PowerBI and this is great to know that you can do things like this.
Also good to know that RELATED doesnt work with M2M.
Chris
Hi @cwozniak03 ,
As the screenshot you shared. The relationship between tables are M2M. That should be the case. Is it possbile to change it to 1:N or create a bridge table to work on it?
User | Count |
---|---|
116 | |
62 | |
59 | |
48 | |
39 |
User | Count |
---|---|
111 | |
65 | |
63 | |
51 | |
48 |