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
Sergi
Frequent Visitor

Convert YTD volumes (accumulative) to monthly volumes

Hi all,

 

Hope some could find a solution.  I have a date sheet where the volumes by month shows only the accumulative volumes considering the months before.  and I would like to add a column that showed me the absulute monthly volumes.

 

The fields in my case are  date (year.month),  sales (€), customers

 

I've just looked in another forums, but with no success with the formulas.

 

ex. 

Date       Sales

2023.1    5

2023.2    8

2023.3    10

 

and i would like to see

Date       Sales

2023.1    5

2023.2    3

2023.3    2

 

 

8 REPLIES 8
Ahmedx
Super User
Super User

pls try rhis

Column = 
VAR _CurrentDate ='Table'[Date]
RETURN
'Table'[Sales]-
CALCULATE(
    max( 'Table'[Sales] ),ALL('Table'),
  
    'Table'[Date]<_CurrentDate)

Screenshot_1.png

Sergi
Frequent Visitor

Hi, 

Just forgot to mention, that have several values for each Date due to customer fields. 

I 'm having the error, that cannot be a unique value for the column Date.

show an example and the result you expect

Sergi
Frequent Visitor

Should be like this:

 

Sergi_0-1697026090549.png

 

Hi @Sergi 

You can create a measure

Measure =
VAR a =
    MINX ( ALLSELECTED ( 'Table' ), [Date] )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[Date] ) = a,
        CALCULATE ( SUM ( 'Table'[Sales] ) ),
        SUM ( 'Table'[Sales] )
            - CALCULATE (
                SUM ( 'Table'[Sales] ),
                OFFSET ( -1, ALLSELECTED ( 'Table'[Date] ), ORDERBY ( [Date], ASC ) )
            )
    )

Output

vxinruzhumsft_0-1697165401331.png

Best Regards!

Yolo Zhu

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

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Convert YTD volumes.pbix

Sergi
Frequent Visitor

Hi, could you write the formula, please. Cannot download the file due to enterprise privileges.

 

Regards,

 

Sergi

Screenshot_2.png

 

_Sales = sum('Table'[Sales]) 
----------
Final = IF(
    ISFILTERED( 'Table'[Customer] ), [_Sales]-
    CALCULATE(
        [_Sales],
        OFFSET(
            -1,
            SUMMARIZE(
                ALLSELECTED( 'Table' ),
                'Table'[Customer],
                'Table'[Date]
            ),
            ORDERBY( 'Table'[Date] ),DEFAULT,PARTITIONBY('Table'[Customer])
        )
    ), [_Sales]-
    CALCULATE(
        [_Sales],
        OFFSET(
            -1,
            SUMMARIZE( ALLSELECTED( 'Table' ), 'Table'[Date] ),
            ORDERBY( 'Table'[Date] )
        )
    )
)

 

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.