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
Anonymous
Not applicable

Calculer la somme d'une valeur pour chaque semaine

Hi community ,

 

       Est ce qu'il exciste une formule ou un moyen pour calculer une somme d'une valeur par semaine .

 

cordialement 

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to use the following measure to meet your requirement:

 

TotalValueOfWeek =
VAR w =
    WEEKNUM ( MIN ( 'Table'[Date] ) )
VAR y =
    YEAR ( MIN ( 'Table'[Date] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            WEEKNUM ( 'Table'[Date] ) = w
                && YEAR ( 'Table'[Date] ) = y
        )
    )

 

2.jpg

 


If it doesn't meet your requirement, Please show the exact expected result based on the Tables that we have shared.


Best regards,

 

Community Support Team _ Dong Li
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

3 REPLIES 3
RedYsl
Frequent Visitor

Hi,

I have a similar case where I need to display for every product the sales of a specific period : 5 weeks since its first  launch.
It's exactly the solution you gave :

Sales First 5 weeks = 
VAR _WeekStart = [# First Week]
VAR _WeekEnd = [# Last Week]
RETURN CALCULATE( SUM(Fact_Sales[Sales]),
FILTER( Fact_Sales, Fact_Sales[Week Id] >= _WeekStart && Fact_Sales[Week Id] <= _WeekEnd)
)

It's working fine, except that when added on a grid, the grand total  is not the sum of every single product's sales.
The filter is also applied to the total..
In other words, it calculates the total sales from the MIN week of ALL products, until the week calculated as MIN + 4 weeks.
Which is not the behavior I want.
For the grand total, I only need the sum of every single row.

Can anybody advise which can be the solution ?

Thanks

v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to use the following measure to meet your requirement:

 

TotalValueOfWeek =
VAR w =
    WEEKNUM ( MIN ( 'Table'[Date] ) )
VAR y =
    YEAR ( MIN ( 'Table'[Date] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            WEEKNUM ( 'Table'[Date] ) = w
                && YEAR ( 'Table'[Date] ) = y
        )
    )

 

2.jpg

 


If it doesn't meet your requirement, Please show the exact expected result based on the Tables that we have shared.


Best regards,

 

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

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.