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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dannyboy123
Frequent Visitor

Incorrect total

Hi. I have the total2024 measured filtered by using HASONEVALUE and returning blank if it does.  This has left 4 weeks in th visual, but the total is wrong.  I could just turn it off, but it's something I'd really like to understand if poss.  Would really appreciate any advice

 

dannyboy123_0-1740092173665.png

 

totalcount =
sumx(VALUES(Data[Week]),sum(Data[Parcels]))
 
total2024 =
var ly = MAXX(all(data), Data[Year]) -1
return if(SELECTEDVALUE(Data[Year]), blank(), sumx(filter(Data,Data[Year]=ly), [totalcount]))

 

4 REPLIES 4
MFelix
Super User
Super User

Hi @dannyboy123 ,

 

The question on this is that you are using the IF statement and HASONEVALUE this means that at the week level you only have one week so it picks up the correct value however when you look at the total level you have more than one week because the context changes so instead of doing the SUMX with the filtering it only applies the first calculation and sums all of the values for all the weeks.

 

Looking at your code it's seems to be that something is not quite right also because your if statment is SELECTEDVALUE(Data[Year]) you are no doing any comparision or anything else you are just getting the value for the YEAR what is that you want to achieve?

 

This measure may be changed to get the correct SUM at the total level but I'm not understanding the example and the code.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



I have data for some of 2024 weeks and some of 2025 weeks, with a crossover of the two since week 37

 

dannyboy123_0-1740133025135.png

If I don't check the code using hasonevalue, I end up with a lot of empty cells for either one year or the other. I only want to display those where there is a comparison to be made

Hi @dannyboy123 ,

 

I have tried to do a mockup but the measures are not working has you show it on the images.

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi.  I have data for part of last year and part of this year.  I only want to display rows where there is data for both.  Hasonevalue seems to support this, because I can return blank if there are two years being filtered.  Otherwise, Id have two columns, both with largely empty values in one of them.  The only weeks I have data for both are weeks 37-40, so they are the only ones I want to display

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.