The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I'm trying to write a measure that returns a true/false if all the values in a filtered table column are the same or not.
Example:
ID | Sale |
123 | $50 |
123 | $60 |
456 | $20 |
I don't want to do any aggregating of the Sale value, but I want to give a visual indicator (changing the color of the the text) that the table has been filtered down to a single ID (assume there are other columns giving details about the individual sales, and the stakeholder would be interested in seeing the line items for a single ID at a time).
I am looking for a measure I can use to evaluate if the ID filter has been applied, such that only IDs of the same value appear in the table. I tried doing COUNT and DISTINCTCOUNT, such that I could write the rule to be if the number of uniques = 1 then apply, but it's only evaluating on a row basis:
ID | Sales | Unique |
123 | $50 | 2 |
123 | $60 | 2 |
456 | $20 | 1 |
What I would be expecting though is the UNIQUE column would show 2 for all rows, because there are 2 unique ID values, instead of telling me how many rows there are for each ID.
DAX is new to me, and if I were trying to do this in R in would be a simple: measure <- IF(length(unique(Table[ID])=1, #000000, #CCCCCC) -- but I can't figure out how to translate that to DAX
Solved! Go to Solution.
Hi @jam17
It's not that much clear for me. are you looking for count of ID's?? if so, then you can write a measure as follows:
I am pulling in a Table Vis onto the report to display line items of sales (among other summary cards).
With no filtering, it will show all line items. I have a slicer on my report to select a particular ID (customer), which filters the Table Vis to just those sales with that ID. I want something to indicate that the Table Vis is only displaying a single ID's worth of information.
Table Vis (unfiltered)
IDs |
123 |
123 |
456 |
789 |
456 |
Here there is more than one unique ID in the list. Text should be grey.
>> APPLY SLICER: ID = 123 <<
Table Vis Filter
ID |
123 |
123 |
Here this is only one unique ID. Text should be black.
you can use the measure in previous post in setting, cell elements, font color , and define rule.
If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.
Hi @jam17
It's not that much clear for me. are you looking for count of ID's?? if so, then you can write a measure as follows:
User | Count |
---|---|
60 | |
55 | |
53 | |
49 | |
30 |
User | Count |
---|---|
179 | |
87 | |
70 | |
48 | |
45 |