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 August 31st. Request your voucher.
Hi,
I have used a simple dax measure to count the number of incidents but whenever I use selectedvalue function in the measure I get incorrect numbers in the chart however correct numbers reflect in the card visual. Any help highly appreciated.
Solved! Go to Solution.
Hi @Vijay08V
Sorry for the late reply. The solution is to add a 'Years' table to the model to have all year values from the sample table and create a one-to-many relationship from 'Years' table to Sample table on Year column.
Then use 'Years' table's Year column in SELECTEDVALUE function in the measure and in the Year slicer too.
VOLUME COUNT = CALCULATE(COUNT('Sample'[Number]),'Sample'[YEAR]=SELECTEDVALUE('Years'[YEAR],YEAR(TODAY())))
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi @Vijay08V
I don't see any Year value from your visuals. Do you have any filter or slicer in the report to select a year?SELECTEDVALUE only returns one distinct value in the current context. If there are more than one distinct values, it returns the alternateResult.
In addition, can you please share some sample data of the table as well as the expected result based on it?
Best Regards,
Community Support Team _ Jing
Yes I have a year filter for the visual. The desired output is to get current year count in the visual if year slicer is not selected and the counts in visual should change upon changing the year filter. Also what I notice is that this issue is occuring only when I add any category in the Legend field.
I was not able to attach the sample pbix file in this thread hence attaching as drive link
https://drive.google.com/file/d/1t2yiufHvwMCbg7V0Vph-JGg2AN-Bh97i/view?usp=drivesdk
Hi @Vijay08V
Sorry for the late reply. The solution is to add a 'Years' table to the model to have all year values from the sample table and create a one-to-many relationship from 'Years' table to Sample table on Year column.
Then use 'Years' table's Year column in SELECTEDVALUE function in the measure and in the Year slicer too.
VOLUME COUNT = CALCULATE(COUNT('Sample'[Number]),'Sample'[YEAR]=SELECTEDVALUE('Years'[YEAR],YEAR(TODAY())))
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
It worked. Thank you very much!
Can someone help me on this
VOLUME COUNT = CALCULATE(COUNT(TBL_Sample[Number]),FILTER(TBL_Sample,TBL_Sample[YEAR]=SELECTEDVALUE(TBL_Sample[YEAR],YEAR(TODAY()))))
or try
VOLUME COUNT = CALCULATE(COUNT(TBL_Sample[Number]),ALL(TBL_Sample),TBL_Sample[YEAR]=SELECTEDVALUE(TBL_Sample[YEAR],YEAR(TODAY())))
Tried the first dax but still same issue and second one gave a totally different number