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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
santoshlearner2
Resolver I
Resolver I

Sum of Daily Changes into Months and Financial Year

Dear All,

 

I have a table where there is calculated column, datewise it does the daily balance, which is nothing but deducting the currently value with the previous, this number i have on a daily basis, how to get a calculated column or a measure which will give me the respective monthly total ( of the daily values ) and the financial year total in a seperate column (financial year starts from March).

 

Please note the table is divide into category and sub category wise, hence need to calculate those respective values. Daily i am getting but monthly and Financial year is giving an error.

 

thank you all.

 

DateStoreMain ProductSub ProductFinal sales  is from a measure (basicaly deducting previous date and current date)
31-01-2024DelhiBikeTyres100
31-01-2024mumbaiBikeChain154
31-01-2024goaBikeBucket160
31-01-2024bandraCarWindshield210
31-01-2024KharCarAccessories230
31-01-2024NagpurCarPencil260
31-01-2024NorthRulersSmall100
31-01-2024SouthRulersBig154
31-01-2024ChennaiRulersMedium160
30-01-2024DelhiBikeTyres210
30-01-2024mumbaiBikeChain230
30-01-2024goaBikeBucket260
30-01-2024bandraCarWindshield100
30-01-2024KharCarAccessories110
30-01-2024NagpurCarPencil155
30-01-2024NorthRulersSmall156
30-01-2024SouthRulersBig210
30-01-2024ChennaiRulersMedium260
28-01-2024DelhiBikeTyres78
28-01-2024mumbaiBikeChain452
28-01-2024goaBikeBucket460
28-01-2024bandraCarWindshield450
28-01-2024KharCarAccessories136
28-01-2024NagpurCarPencil156
28-01-2024NorthRulersSmall850
28-01-2024SouthRulersBig1230
28-01-2024ChennaiRulersMedium120
1 ACCEPTED SOLUTION
v-junyant-msft
Community Support
Community Support

Hi @santoshlearner2 ,

Please check if this is what you want? I have calculated the sum of daily balance for each month and each fiscal year for different combinations of Main Product and Sub Product.
Here is the sample data:
DateMain ProductSub ProductFinal sales

2023.1.31 Bike Tyres 10
2023.1.31 Bike Chain 20
2023.1.31 Car Windshield 30
2023.1.31 Car Accessories 40
2023.1.15 Bike Tyres 50
2023.1.15 Bike Chain 60
2023.1.15 Car Windshield 70
2023.1.15 Car Accessories 80
2023.3.31 Bike Tyres 90
2023.3.31 Bike Chain 100
2023.3.31 Car Windshield 110
2023.3.31 Car Accessories 120
2023.3.15 Bike Tyres 130
2023.3.15 Bike Chain 140
2023.3.15 Car Windshield 150
2023.3.15 Car Accessories 160
2023.5.31 Bike Tyres 170
2023.5.31 Bike Chain 180
2023.5.31 Car Windshield 190
2023.5.31 Car Accessories 200
2023.5.15 Bike Tyres 210
2023.5.15 Bike Chain 220
2023.5.15 Car Windshield 230
2023.5.15 Car Accessories 240
2023.7.31 Bike Tyres 250
2023.7.31 Bike Chain 260
2023.7.31 Car Windshield 270
2023.7.31 Car Accessories 280
2023.7.15 Bike Tyres 290
2023.7.15 Bike Chain 300
2023.7.15 Car Windshield 310
2023.7.15 Car Accessories 320
2023.9.30 Bike Tyres 330
2023.9.30 Bike Chain 340
2023.9.30 Car Windshield 350
2023.9.30 Car Accessories 360
2023.9.15 Bike Tyres 370
2023.9.15 Bike Chain 380
2023.9.15 Car Windshield 390
2023.9.15 Car Accessories 400
2023.11.30 Bike Tyres 410
2023.11.30 Bike Chain 420
2023.11.30 Car Windshield 430
2023.11.30 Car Accessories 440
2023.11.15 Bike Tyres 450
2023.11.15 Bike Chain 460
2023.11.15 Car Windshield 470
2023.11.15 Car Accessories 480
2024.1.31 Bike Tyres 490
2024.1.31 Bike Chain 500
2024.1.31 Car Windshield 510
2024.1.31 Car Accessories 520
2024.1.15 Bike Tyres 530
2024.1.15 Bike Chain 540
2024.1.15 Car Windshield 550
2024.1.15 Car Accessories 560
2024.3.31 Bike Tyres 570
2024.3.31 Bike Chain 580
2024.3.31 Car Windshield 590
2024.3.31 Car Accessories 600
2024.3.15 Bike Tyres 610
2024.3.15 Bike Chain 620
2024.3.15 Car Windshield 630
2024.3.15 Car Accessories 640
2024.5.31 Bike Tyres 650
2024.5.31 Bike Chain 660
2024.5.31 Car Windshield 670
2024.5.31 Car Accessories 680
2024.5.15 Bike Tyres 690
2024.5.15 Bike Chain 700
2024.5.15 Car Windshield 710
2024.5.15 Car Accessories 720
2024.7.31 Bike Tyres 730
2024.7.31 Bike Chain 740
2024.7.31 Car Windshield 750
2024.7.31 Car Accessories 760


Use these DAXs to create two calculated columns:

monthly total = 
VAR _CurrentMonth = MONTH([Date])
VAR _CurrentYear = YEAR([Date])
VAR _MainProduct = [Main Product]
VAR _SubProduct = [Sub Product]
RETURN
CALCULATE(
    [daily balance],
    FILTER(
        ALL('Table'),
        MONTH('Table'[Date]) = _CurrentMonth && YEAR('Table'[Date]) = _CurrentYear && 'Table'[Main Product] = _MainProduct && 'Table'[Sub Product] = _SubProduct
    )
)
financial year total = 
VAR _CurrentMonth = MONTH([Date])
VAR _CurrentYear = YEAR([Date])
VAR _MainProduct = [Main Product]
VAR _SubProduct = [Sub Product]
VAR Monthlessthan3 = 
CALCULATE(
    [daily balance],
    FILTER(
        ALL('Table'),
        'Table'[Date] >= DATE(_CurrentYear - 1, 3, 1) && 'Table'[Date] < DATE(_CurrentYear, 3, 1) && 'Table'[Main Product] = _MainProduct && 'Table'[Sub Product] = _SubProduct
    )
)
VAR Monthmorethan3 = 
CALCULATE(
    [daily balance],
    FILTER(
        ALL('Table'),
        'Table'[Date] >= DATE(_CurrentYear, 3, 1) && 'Table'[Date] < DATE(_CurrentYear + 1, 3, 1) && 'Table'[Main Product] = _MainProduct && 'Table'[Sub Product] = _SubProduct
    )
)
RETURN
IF(
    _CurrentMonth < 3,
    Monthlessthan3,
    Monthmorethan3
)

And the final output is as below:

vjunyantmsft_0-1724295249906.png


Best Regards,
Dino Tao
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
v-junyant-msft
Community Support
Community Support

Hi @santoshlearner2 ,

Please check if this is what you want? I have calculated the sum of daily balance for each month and each fiscal year for different combinations of Main Product and Sub Product.
Here is the sample data:
DateMain ProductSub ProductFinal sales

2023.1.31 Bike Tyres 10
2023.1.31 Bike Chain 20
2023.1.31 Car Windshield 30
2023.1.31 Car Accessories 40
2023.1.15 Bike Tyres 50
2023.1.15 Bike Chain 60
2023.1.15 Car Windshield 70
2023.1.15 Car Accessories 80
2023.3.31 Bike Tyres 90
2023.3.31 Bike Chain 100
2023.3.31 Car Windshield 110
2023.3.31 Car Accessories 120
2023.3.15 Bike Tyres 130
2023.3.15 Bike Chain 140
2023.3.15 Car Windshield 150
2023.3.15 Car Accessories 160
2023.5.31 Bike Tyres 170
2023.5.31 Bike Chain 180
2023.5.31 Car Windshield 190
2023.5.31 Car Accessories 200
2023.5.15 Bike Tyres 210
2023.5.15 Bike Chain 220
2023.5.15 Car Windshield 230
2023.5.15 Car Accessories 240
2023.7.31 Bike Tyres 250
2023.7.31 Bike Chain 260
2023.7.31 Car Windshield 270
2023.7.31 Car Accessories 280
2023.7.15 Bike Tyres 290
2023.7.15 Bike Chain 300
2023.7.15 Car Windshield 310
2023.7.15 Car Accessories 320
2023.9.30 Bike Tyres 330
2023.9.30 Bike Chain 340
2023.9.30 Car Windshield 350
2023.9.30 Car Accessories 360
2023.9.15 Bike Tyres 370
2023.9.15 Bike Chain 380
2023.9.15 Car Windshield 390
2023.9.15 Car Accessories 400
2023.11.30 Bike Tyres 410
2023.11.30 Bike Chain 420
2023.11.30 Car Windshield 430
2023.11.30 Car Accessories 440
2023.11.15 Bike Tyres 450
2023.11.15 Bike Chain 460
2023.11.15 Car Windshield 470
2023.11.15 Car Accessories 480
2024.1.31 Bike Tyres 490
2024.1.31 Bike Chain 500
2024.1.31 Car Windshield 510
2024.1.31 Car Accessories 520
2024.1.15 Bike Tyres 530
2024.1.15 Bike Chain 540
2024.1.15 Car Windshield 550
2024.1.15 Car Accessories 560
2024.3.31 Bike Tyres 570
2024.3.31 Bike Chain 580
2024.3.31 Car Windshield 590
2024.3.31 Car Accessories 600
2024.3.15 Bike Tyres 610
2024.3.15 Bike Chain 620
2024.3.15 Car Windshield 630
2024.3.15 Car Accessories 640
2024.5.31 Bike Tyres 650
2024.5.31 Bike Chain 660
2024.5.31 Car Windshield 670
2024.5.31 Car Accessories 680
2024.5.15 Bike Tyres 690
2024.5.15 Bike Chain 700
2024.5.15 Car Windshield 710
2024.5.15 Car Accessories 720
2024.7.31 Bike Tyres 730
2024.7.31 Bike Chain 740
2024.7.31 Car Windshield 750
2024.7.31 Car Accessories 760


Use these DAXs to create two calculated columns:

monthly total = 
VAR _CurrentMonth = MONTH([Date])
VAR _CurrentYear = YEAR([Date])
VAR _MainProduct = [Main Product]
VAR _SubProduct = [Sub Product]
RETURN
CALCULATE(
    [daily balance],
    FILTER(
        ALL('Table'),
        MONTH('Table'[Date]) = _CurrentMonth && YEAR('Table'[Date]) = _CurrentYear && 'Table'[Main Product] = _MainProduct && 'Table'[Sub Product] = _SubProduct
    )
)
financial year total = 
VAR _CurrentMonth = MONTH([Date])
VAR _CurrentYear = YEAR([Date])
VAR _MainProduct = [Main Product]
VAR _SubProduct = [Sub Product]
VAR Monthlessthan3 = 
CALCULATE(
    [daily balance],
    FILTER(
        ALL('Table'),
        'Table'[Date] >= DATE(_CurrentYear - 1, 3, 1) && 'Table'[Date] < DATE(_CurrentYear, 3, 1) && 'Table'[Main Product] = _MainProduct && 'Table'[Sub Product] = _SubProduct
    )
)
VAR Monthmorethan3 = 
CALCULATE(
    [daily balance],
    FILTER(
        ALL('Table'),
        'Table'[Date] >= DATE(_CurrentYear, 3, 1) && 'Table'[Date] < DATE(_CurrentYear + 1, 3, 1) && 'Table'[Main Product] = _MainProduct && 'Table'[Sub Product] = _SubProduct
    )
)
RETURN
IF(
    _CurrentMonth < 3,
    Monthlessthan3,
    Monthmorethan3
)

And the final output is as below:

vjunyantmsft_0-1724295249906.png


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

Hello Dino,

 

Thank you for your reply, appreciate your help. There is one issue, what is happening is for monthly change, it sums all the days and gives a higher figure than the actual for example Jan-23 if it s360 it shows 720.

Hi @santoshlearner2 ,

I apologize that I may not have understood you well. Is this reply of yours talking about my provided DAX and sample data?
You said “for example Jan-23 if it s360 it shows 720”, which seems to mean that the sum of all the data corresponding to Jan-23 in my sample data is equal to 360, but didn't you say in your original requirement that you want to “divide into category and sub category wise, hence need to calculate those respective values”, please confirm what exactly is your Monthly total calculation?

Best Regards,
Dino Tao

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.