Forum Discussion

SebSchoon1's avatar
SebSchoon1
Icon for Post Patron rankPost Patron
4 years ago
Solved

Trunc does not provide expected results

Hi guys,

 

I use this formula

 

TRUNC([Répartition],0) and visually get the correct values.
 
However total is not correct, it takes the decimal value into account but it should be 9 any chance to help me with this?
 

 

here's the formula used ( thanks community!!) to get the [Répartition] part

 

Répartition = VAR SummaryTable =

    ADDCOLUMNS (

        SUMMARIZE (

            'Tableau Dispatch',

            'Base Article'[CODE ARTICLE],

            'Tableau Dispatch'[CODE DEPOT]

        ),

        "@val",

            VAR QTETOT = [1-Total articles en stock]

            VAR QTETOTDEPOT =

                CALCULATE (

                    [1-Total articles en stock],

                    REMOVEFILTERS ( 'Tableau Dispatch'[CODE DEPOT] )

                )

            RETURN

                DIVIDE (

                    CALCULATE ( QTETOTDEPOT, ALL ( 'Tableau Dispatch'[CODE DEPOT] ) ),

                    [Total dépots],

                    BLANK ()

                )

    )

RETURN

    SUMX ( SummaryTable, [@val] )

 

  • HI guys,

    lbendlin , Anonymous 

     

    Thanks to johnt75 

     

    I Used 

     

    partie entière répartition = 

    VAR SummaryTable =

        ADDCOLUMNS (

            SUMMARIZE (

                'Tableau Dispatch',

                'Base Article'[CODE ARTICLE],

                'Tableau Dispatch'[CODE DEPOT]

            ),

            "@val",

                VAR QTETOT = [1-Total articles en stock]

                VAR QTETOTDEPOT =

                    CALCULATE (

                        [1-Total articles en stock],

                        REMOVEFILTERS ( 'Tableau Dispatch'[CODE DEPOT] )

                    )

                RETURN

                    DIVIDE (

                        CALCULATE ( QTETOTDEPOT, ALL ( 'Tableau Dispatch'[CODE DEPOT] ) ),

                        [Total dépots],

                        BLANK ()

                    )

        )

    RETURN

        SUMX ( SummaryTable, TRUNC([@val]) )
     

    Seriously guys, Thank you so much !

     

3 Replies

  • Do another SUMX, this time over the TRUNC  function.  Remember that in a table visual measures are calculated twice, once for each row-column , and once for the row total.

     

    If you want further help please provide sanitized sample data that fully covers your issue.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  SebSchoon1 ,

    Here are the steps you can follow:

    1. Create measure.

    Measure =
    var _table=
    SUMMARIZE('Table','Table'[Index],"Value",[partie entiere repartition])
    return
    IF(
        HASONEVALUE('Table'[Index]),[partie entiere repartition],SUMX(_table,[Value]))

    2. Result:

     

    Best Regards,

    Liu Yang

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

  • HI guys,

    lbendlin , Anonymous 

     

    Thanks to johnt75 

     

    I Used 

     

    partie entière répartition = 

    VAR SummaryTable =

        ADDCOLUMNS (

            SUMMARIZE (

                'Tableau Dispatch',

                'Base Article'[CODE ARTICLE],

                'Tableau Dispatch'[CODE DEPOT]

            ),

            "@val",

                VAR QTETOT = [1-Total articles en stock]

                VAR QTETOTDEPOT =

                    CALCULATE (

                        [1-Total articles en stock],

                        REMOVEFILTERS ( 'Tableau Dispatch'[CODE DEPOT] )

                    )

                RETURN

                    DIVIDE (

                        CALCULATE ( QTETOTDEPOT, ALL ( 'Tableau Dispatch'[CODE DEPOT] ) ),

                        [Total dépots],

                        BLANK ()

                    )

        )

    RETURN

        SUMX ( SummaryTable, TRUNC([@val]) )
     

    Seriously guys, Thank you so much !