Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Vijay08V
Helper III
Helper III

Incorrect Count DAX Function -- Need help

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.

 

VOLUME COUNT = CALCULATE(COUNT(TBL_Sample[Number]),TBL_Sample[YEAR]=SELECTEDVALUE(TBL_Sample[YEAR],YEAR(TODAY())))

 

 


image.png

 

 

 

1 ACCEPTED 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.   vjingzhang_1-1675068517985.png

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())))

 

vjingzhang_2-1675068855974.png

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

7 REPLIES 7
v-jingzhang
Community Support
Community Support

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.   vjingzhang_1-1675068517985.png

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())))

 

vjingzhang_2-1675068855974.png

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!

Vijay08V
Helper III
Helper III

Can someone help me on this

jaweher899
Impactful Individual
Impactful Individual

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.