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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
juan_pablo
Advocate III
Advocate III

substract dax

Hi, 

I'm trying to do a simple thing: just substract one unit (1) from a measure, but when I do this, the rows become all rows of the model as the imagen shows: the result must be 7 and 2 in the TWO rows of the current table, not -1 in all rows of the model.

 

This is the measure:

Ahorro=COUNT('(5) MR Header Fields'[srnScnNumber])

 

 Measure.JPG

 

Ahorro=COUNT('(5) MR Header Fields'[srnScnNumber])-1

 

Measure -1.JPG 

Why this happens and how can I solve it?

Thank you very much.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

It's subtracting 1 even from all of the rows that return a blank count.

 

Try something like this instead:

 

Ahorro=
VAR Cnt = COUNT('(5) MR Header Fields'[srnScnNumber])
RETURN IF(ISBLANK(Cnt), BLANK(), Cnt - 1)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @juan_pablo,

 

Matrix visuals will auto hide blank records(you can right click on row or column fields and choose 'show item with no data' to force display them).


When you add "-1" or other calculation on it, it will try to transform blank value as zero then calculate with numeric value you define.


So I'd like to suggest you add condition on category column to ignore calculate on records which not has value.

 

Regards,

Xiaoxin Sheng

AlexisOlson
Super User
Super User

It's subtracting 1 even from all of the rows that return a blank count.

 

Try something like this instead:

 

Ahorro=
VAR Cnt = COUNT('(5) MR Header Fields'[srnScnNumber])
RETURN IF(ISBLANK(Cnt), BLANK(), Cnt - 1)

Thank you very much! It works great.

If you have time, can you please explain me a little bit better why this happens and why your solution works?

If not, it's ok.

Thank you.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors