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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
johnyip
Super User
Super User

Errors of "row subtotals" of a matrix

I have a hypothetical set of data as shown as beow figure: sales of 5 shops and their respective sales and target. The "Sales vs Target" is a measure simply defined by subtracting target from sales.

 

matrix_issue.png

 

Note that there is a shop (shop E) that does not have any target. I have deliberately specified that in the measure to refrain "Sales vs Target" from displaying the figure (1245) which is wrong.

 

However, the total fails to comply with the deliberated result, and have that 1245 included in the calculation (200-500+2300+200=2200 only. The calculated 3445 counts the 1245 that I deliberately missed out.)

 

Do I do nything wrong in defining the measure? Please help.

 

 

https://drive.google.com/file/d/1TT3NHYn4ILF_TySILLLcBx9pfmN1Q6gj/view?usp=sharing

 



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!
3 ACCEPTED SOLUTIONS
davehus
Memorable Member
Memorable Member

Hi @johnyip ,

 

Please try 

Measure = CALCULATE(SUMX(Sheet1,Sheet1[Sales]-Sheet1[Target]), FILTER(Sheet1,Sheet1[Target]>0))
 
davehus_0-1651245569790.png

Did I help you today? Please accept my solution and hit the Kudos button.

View solution in original post

v-yalanwu-msft
Community Support
Community Support

Hi, @johnyip ;

May be you could modify the measure .

Sales vs Target = 
CALCULATE( SUM(Sheet1[Sales])-SUM([Target]),FILTER('Sheet1',[Target]<>BLANK()))

The final output is shown below:

vyalanwumsft_0-1651543448792.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

v-yalanwu-msft
Community Support
Community Support

Hi, @johnyip ;

If it the measure. you could try it.

Measure = CALCULATE([Sales2]-[Target2],FILTER('Sheet1',[Target2]<>BLANK()))

The final output is shown below:

vyalanwumsft_0-1651545546454.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
johnyip
Super User
Super User

Thanks all for the reply and attempts to help. I have taken my temporary solution as the final solution of my issue. Thx.



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!
v-yalanwu-msft
Community Support
Community Support

Hi, @johnyip ;

If it the measure. you could try it.

Measure = CALCULATE([Sales2]-[Target2],FILTER('Sheet1',[Target2]<>BLANK()))

The final output is shown below:

vyalanwumsft_0-1651545546454.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

johnyip
Super User
Super User

Hello all, thanks for the replies and they all work.
But how about if [Sales] and [Target] are both measures?

I have been enlightened by your answers and get a temp workaround to achieve the correct result: creating a column using DAX to record which shop is excluded and use that column as the filter.

Just want to know if there is any proper way (measure DAX) to do that if [Sales] and [Target] are both measures?



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!
v-yalanwu-msft
Community Support
Community Support

Hi, @johnyip ;

May be you could modify the measure .

Sales vs Target = 
CALCULATE( SUM(Sheet1[Sales])-SUM([Target]),FILTER('Sheet1',[Target]<>BLANK()))

The final output is shown below:

vyalanwumsft_0-1651543448792.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

davehus
Memorable Member
Memorable Member

Hi @johnyip ,

 

Please try 

Measure = CALCULATE(SUMX(Sheet1,Sheet1[Sales]-Sheet1[Target]), FILTER(Sheet1,Sheet1[Target]>0))
 
davehus_0-1651245569790.png

Did I help you today? Please accept my solution and hit the Kudos button.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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