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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.