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
Gyuzal0997
Regular Visitor

Row subtotal is incorrect

Hi, everyone.

 

I am facing the problem of displaying row subtotal value correctly. 

In my data I have a hierarchy where there are  outlet codes connected with a person or trade marketer. The goal is to calculate sales fact volume. The formula used is like this 

Sales Fact =
        VAR DSDSalesData =
            CALCULATE (
                SUM ( 'Sales - Fact'[Volume in U] ),
                FILTER ( Sales, Sales[Sales type] = "DSD Sales Data" )
            )
        VAR Alternative =
            CALCULATE (
                SUM ( 'Sales - Fact'[Volume in U] ),
                FILTER ( Sales, Sales[Sales type] = "SD Subdistributor" )
            )
                + CALCULATE (
                    SUM ( 'Order Item - Fact'[Quantity] ) * 20,
                    'Order'[Type] = "Transfer Order",
                    'Order'[Deleted] <> "Y"
                )
        RETURN
            IF ( DSDSalesData > 0, DSDSalesData, Alternative )

When I expand my sales fact value to the lowest level of hierarchy ( outlet code)- the value is right, however when I want to show the total on the person level- value is totally different.
 
Can you suggest any ideas on how to fix this issue?
 
Thanks in advance.
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Gyuzal0997 ,

Please have a try.

Select the only column in the table that has no duplicate values, such as a date column, or create an index column.

 

Then create a measure based on [sales fact].

var _b = SUMMARIZE('sales','sales'[date] or index column,"aaa",'sales'[sales fact])
return
IF(HASONEVALUE('sales'[date] or index column),'sales'[sales fact],SUMX(_b,[aaa]))

 

If I have misunderstood your meaning, please provide more details with screenshots.

 

Best Regards

Community Support Team _ Polly

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Gyuzal0997 ,

Please have a try.

Select the only column in the table that has no duplicate values, such as a date column, or create an index column.

 

Then create a measure based on [sales fact].

var _b = SUMMARIZE('sales','sales'[date] or index column,"aaa",'sales'[sales fact])
return
IF(HASONEVALUE('sales'[date] or index column),'sales'[sales fact],SUMX(_b,[aaa]))

 

If I have misunderstood your meaning, please provide more details with screenshots.

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Gyuzal0997 , You have force visual group by the context in the formula . I should be some common dimesion column

 

Sumx(Values(Table[Column]), IF ( DSDSalesData > 0, DSDSalesData, Alternative ) )

 

 

Use summarize if there are more than one column

refer if needed https://www.youtube.com/watch?v=ufHOOLdi_jk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.