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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SebSchoon1
Post Patron
Post Patron

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?
 
SebSchoon1_1-1663917841275.png

 

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] )

 

1 ACCEPTED SOLUTION
SebSchoon1
Post Patron
Post Patron

HI guys,

@lbendlin , @v-yangliu-msft 

 

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 !

 

View solution in original post

3 REPLIES 3
SebSchoon1
Post Patron
Post Patron

HI guys,

@lbendlin , @v-yangliu-msft 

 

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 !

 

v-yangliu-msft
Community Support
Community Support

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:

vyangliumsft_0-1664161476124.png

 

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

lbendlin
Super User
Super User

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.