Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello experts,
I am trying to create a calculated measure with a condition. The condition needs to look at a dimension and if its a certain data element, do a sum of another measure. Below is what i have if it makes sense
Solved! Go to Solution.
OK, define "wrong". Is it an error, some unexpected value? That is a pretty dirt simple SWITCH statement, not a ton to go wrong there, here it is cleaned up a bit:
SWITCH(
SELECTEDVALUE('public v2_rcnt_6_wks'[Metric]),
"1-16M",CALCULATE(SUM('public v2_rcnt_6_wks'[mtrc_num_delta_row_tot]))
)
Thank you for the quick response. The results are blank. Nothing showing up even though there is data in the table.
Tried the cleaned up version you provided and still the same.
Thanks,
Naizam
Please try
//If based in slicer
var _max = maxx('public v2_rcnt_6_wks',allselected('public v2_rcnt_6_wks'[Metric]))
return
SWITCH(_max,"1-16M",CALCULATE(SUM('public v2_rcnt_6_wks'[mtrc_num_delta_row_tot])))
//if not a slicer
SWITCH(firstnonblank('public v2_rcnt_6_wks'[Metric],blank()),"1-16M",CALCULATE(SUM('public v2_rcnt_6_wks'[mtrc_num_delta_row_tot])))
Hi Amit,
Unfortunately this is also not working. I am wondering if using IF ELSE would make any difference.
Thanks,
Naizam
Below is what i see without using Metric field in the report layout even though there are many other records with data.
And this how it looks after adding Metric field to the layout.
OK, any possibility you can share some sample source data that replicates the problem for this or the PBIX? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Hi @Greg_Deckler ,
Thank you for looking into this. As you mentioned, it is a simple math and i am not sure where it is going wrong.
Below is the link to the pbix.
https://drive.google.com/open?id=12porBnt7aoZxg38MkXxDudMiRCqacOqp
Thanks,
Naizam
Anyone know what could be wrong here? Appreciate any help you can provide.
Thanks,
Naizam
Looking at the pbix, I think you've already proved what's going on with the 2 different tables you have.
The one on the left just has state and the three measures. It only shows data for Marshall Islands and Micronesia. These are the only states where the table can evaluate only one value for Metric. Any other State has more than one record with different Metric. So SelectedValue returns blank.
I tested this by creating a measure
testMeasure = SELECTEDVALUE(Sheet1[Metric])
and putting it on a card. In the left hand table I put 'Show items with no data' on the state field. Click on any state apart from the two mentioned, the card always shows blank.
You have proved with the table on the right that the selectedvalue can return a value because you have added another field to the table. That gives enough detail.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
96 | |
93 | |
82 | |
70 | |
64 |
User | Count |
---|---|
118 | |
106 | |
93 | |
79 | |
72 |