The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
I have products table (Dim) with column "Color" connected to Sales table (fact). with the below DAX I was able to count rows for black and red and same is reflecting against all the colors, but I want to relect the count only against red and black (14,792) and for all other colors it should reflect blank.
Could you please help me to solve this. Thank you.
Solved! Go to Solution.
Hello @gmrram ,
try the following code
# Black and Red =
var sales = CALCULATE(
COUNT(Sales[OrderDate]),
FILTER(ALL(Products), Products[Color] = "Black" || Products[Color] = "Red"))
return
IF(SELECTEDVALUE(Products[Color]) = "Black" ||SELECTEDVALUE(Products[Color]) = "Black",sales,BLANK())
Proud to be a Super User! | |
Hello @gmrram ,
try the following code
# Black and Red =
var sales = CALCULATE(
COUNT(Sales[OrderDate]),
FILTER(ALL(Products), Products[Color] = "Black" || Products[Color] = "Red"))
return
IF(SELECTEDVALUE(Products[Color]) = "Black" ||SELECTEDVALUE(Products[Color]) = "Black",sales,BLANK())
Proud to be a Super User! | |
Hi gmrram
You can create an additional CAlculated Measure as follows, and use that in your table instead. It uses the SWITCH() formula to only display the result of your initial measure, when the column name is "Red" or "Black":
Switch(Products[Color],
"Red", [# Black and Red],
"Black", [# Black and Red],
Blank()
)
_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.
Hi @Jonvoge , Thanks for your reply. It seems your suggested solution is not working as the first argument in Swith function should be expression. Please let me know if I'm missing anyting. However resolved using Selected Value as suggested by Idrissshatila. Thanks again.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
80 | |
77 | |
43 | |
39 |
User | Count |
---|---|
150 | |
116 | |
66 | |
64 | |
55 |