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.
Hello Everone,
Hope you're all doing great!
In my dashboard I have a card called (Student No.) and a filter of 2 choices (Schools - Admin Building), in excel file (resource) I have a column (whole number) for how many student in each school, for admin building it will be 0 all the time. I tried to put N/A instead, but an error occured because its a number column.
what I want is a dax for whenever I select admin building, the card will show the text (N/A), but when I select schools, it will show me the number in the excel file.
Solved! Go to Solution.
Hi @Taamul90
You can create a measure to judge , if the choice is “Schools” , sum the number of students , if the choice is “Admin Building” , return the text “N/A” .
Original data :
Measure :
Measure =
VAR _Schools=CALCULATE(SUM('Table'[number]),FILTER('Table','Table'[choices]="Schools"))
return IF(SELECTEDVALUE('Table'[choices])="Schools",_Schools,"N/A")
The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Taamul90
You can create a measure to judge , if the choice is “Schools” , sum the number of students , if the choice is “Admin Building” , return the text “N/A” .
Original data :
Measure :
Measure =
VAR _Schools=CALCULATE(SUM('Table'[number]),FILTER('Table','Table'[choices]="Schools"))
return IF(SELECTEDVALUE('Table'[choices])="Schools",_Schools,"N/A")
The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I try to apply it on my table, it shows a message (the syntax for return is incorrect), dunno where the problem is
Hi,
Since you only want to display either NA or a number you can circumvent the "variant type error" which you might be encountering by using functions like CONVERT, FORMAT or CONCANETATE. E.g.
Proud to be a Super User!
I tried to make new column in power bi with this DAX
Student_No= Convert( Table_name[column_name(StudentName)], String)
for the card it shows 0 no matter what I chose
@Taamul90 , You can create a column based on slicer selection.
Number to text can done easily like this
Table_name[column_name(StudentName)] & ""
For number of student you can try like
count(Table_name[column_name(StudentName)] )+0
or
countrows(filter(Table_name, Table_name[Building]<> "Admin"), Table_name[column_name(StudentName)]) +0
Thaaank you ValtteriN, but
I think I will face a problem using it, if I convert the column to String, then it won't be able to sum students No. for schools, right ?
It will show numbers as a text, but what I want is, whenever I select School it will sum the number of stuedents, and when I select Admin Building ( by default it will sum the 0), number of students will be always 0 so once it reads 0 it will reflect a text (N/A) on the card
do I made it clear ?
User | Count |
---|---|
15 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |