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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Analitika
Post Prodigy
Post Prodigy

Wrong calculation if adding column in table in Power BI

Hi,

 

I am having question. I have situation when in one case sum of rows values in table is correct in another case when I adding new column in visual, then appears new row and sum of rows becomes incorrect. How I could fix it?

 

Analitika_1-1663241916004.png

6264,00+33,71+34,80 is not equal 6298,75 This comes 3 lines if I add OBJ_KOD column.

 

6264,00+34,80 is equal 6298.. Here getting two lines without adding OBJ_KOD column. in table

 

So how to resolve this issue?

 

total/hs_tb = 
IF (
    ISINSCOPE ( tb[OPALGA_MEN] ),
    DIVIDE ( [total_sum_tb], [sum_hs_tb] ),
    VAR summaryTable =
        ADDCOLUMNS (
            VALUES ( tb[OPALGA_MEN] ),
            "@val", DIVIDE ( [total_sum_tb], [sum_hs_tb] )
        )
    RETURN
        SUMX ( summaryTable, [@val] )
)

Here is a measure for a last column in visual.

 

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Analitika 

 

This part of your formula should be problematic.

VAR summaryTable =
        ADDCOLUMNS (
            VALUES ( tb[OPALGA_MEN] ),
            "@val", DIVIDE ( [total_sum_tb], [sum_hs_tb] )
        )

Depending on the data you provide, the dates are the same and such a result will appear.

vzhangti_0-1663320424765.png

So the result of summation is not quite right.

 

You can try the following methods.

total/hs_tb = 
Var _table=SUMMARIZE('Table','Table'[Date],'Table'[sum1],"val",DIVIDE([total_sum_tb],[sum_hs_tb]))
Var _sum=SUMX(_table,[val])
Return
IF(ISINSCOPE('Table'[Date]),DIVIDE([total_sum_tb],[sum_hs_tb]),_sum)
'Table'[sum1] This represents a column of unique values that will not be deduplication.
vzhangti_1-1663320601972.png

At this time, whether you add OBJ_KOD column or not, the result will not change.

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Analitika 

 

This part of your formula should be problematic.

VAR summaryTable =
        ADDCOLUMNS (
            VALUES ( tb[OPALGA_MEN] ),
            "@val", DIVIDE ( [total_sum_tb], [sum_hs_tb] )
        )

Depending on the data you provide, the dates are the same and such a result will appear.

vzhangti_0-1663320424765.png

So the result of summation is not quite right.

 

You can try the following methods.

total/hs_tb = 
Var _table=SUMMARIZE('Table','Table'[Date],'Table'[sum1],"val",DIVIDE([total_sum_tb],[sum_hs_tb]))
Var _sum=SUMX(_table,[val])
Return
IF(ISINSCOPE('Table'[Date]),DIVIDE([total_sum_tb],[sum_hs_tb]),_sum)
'Table'[sum1] This represents a column of unique values that will not be deduplication.
vzhangti_1-1663320601972.png

At this time, whether you add OBJ_KOD column or not, the result will not change.

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.