Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I created a measure with some variable, the measure must show a value if there is something selected, instead it should show %
I've made similar formula with other database and it works, why now it shows always % also if I select something?
The formula is something like this:
Hi, @Giada_Togliatti
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create a measure as below.
Mva =
VAR maxtime= max('Table'[field1])
VAR _sel1 =
COUNTROWS (ALLSELECTED('Table'[field2]) )
VAR _sel2 =
COUNTROWS ( ALLSELECTED('Table'[field3]) )
RETURN
IF (
_sel1 = 1&& _sel2= 1,
CALCULATE(
MAX('Table'[field5]),
FILTER(
ALL('Table'),
'Table'[field4] ="chairs"&&
'Table'[field1]=maxtime
)
),
"%"
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ALLSELECTED does the opposite of what you want to do, if you want to see what's selected, i assume in slicers, then you should just use countrows on your table, whatever it counts, that what has been selected, distinict(columnName) will give you all the distinct values that have been selected
@andre , @Pragati11 , @amitchandak
I tried to remove allselected but it gives me error, I tried to change allselected with distinct but it doesn't work, I see always %
field1 | field2 | field3 | field4 | field5 |
201806 | string1 | string4 | chairs | 5 |
201906 | string1 | string5 | chairs | 6 |
201806 | string2 | string6 | table | 9 |
201906 | string3 | string6 | table | 7 |
field 2 and field3 are used in slicer
I shoud do a formula like this:
mwa=
VAR maxtime=
max(field1)
VAR _sel1 =
COUNTROWS (allslected( field2) )
VAR _sel2 =
COUNTROWS ( allselected( field3) )
RETURN
IF (
_sel1 = 1
&& _sel2= 1,
CALCULATE(max(field5),
[field4]="chairs",
[field1]=maxtime), "%")
Hi, @Giada_Togliatti
If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.
Best Regards
Allan
@Giada_Togliatti , I doubt there some mismatch at [field5]= maxtime
Can you share sample data and sample output in table format?
Hi @Giada_Togliatti ,
Just wanted to check why you are using ALLSELECTED in the measure? (highlighted)
@Pragati11, allselected is the dax formula, in other situation it works, after allselected I used tablename(fieldname), I used allselected because I must consider the selection of field1 and field2 that are used in slicer
Hi @Giada_Togliatti ,
Try removing ALLSELECTED from your measure with COUNTROWS and test.
If it doesn't work, share some sample pbix file to check for the issue.
Thanks,
Pragati
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
69 | |
55 | |
37 | |
35 |
User | Count |
---|---|
85 | |
66 | |
59 | |
46 | |
45 |