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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Luis98
Resolver II
Resolver II

Acumulate fortnight

Hi, I´m new here and have a doubt about DAX.

 

Yesterday I was dealing with the purchase attachment and wanted to create a table with the following information:

Knowing that the supplier ship on the 15th and 1st of each month, I wanted a table that would accumulate those purchases on the days they ship, to get a table showing how much quantity I will receive on each day.

I tried to do a DAX measure with MTD and with this I was able to get the 15th day, but I am not able to get the 1st day.

 

Any suggestions?

 

Thanks.

 

Date Purchases
2022/01/05 706
2022/01/10 1312
2022/01/22 806
2022/01/27 210
2022/02/02 1037
2022/02/10 1808
2022/02/17 1311
2022/02/25 1793
2022/03/03 1500
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @Luis98 ,

 

Please follow the steps:

1.Create a new table

vbinbinyumsft_0-1658106668030.png

The model:

vbinbinyumsft_1-1658106685754.png

 

2.Create a table visual, and create a measure

Shipment =
VAR cur_date =
    MAX ( 'Table 4'[Dates] )
VAR pre_date =
    CALCULATE (
        MAX ( 'Table 4'[Dates] ),
        FILTER ( ALL ( 'Table 4' ), 'Table 4'[Dates] < cur_date )
    )
VAR temp_table =
    CALCULATETABLE (
        'Table 3',
        'Table 3'[Date] <= cur_date
            && 'Table 3'[Date] >= pre_date
    )
RETURN
    CALCULATE ( [sum_purchase], temp_table )

vbinbinyumsft_2-1658106758658.png

 


If I misunderstand your demands, please feel free to let me know.


Best regards,
Community Support Team_ Binbin Yu
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-binbinyu-msft
Community Support
Community Support

Hi @Luis98 ,

 

Please follow the steps:

1.Create a new table

vbinbinyumsft_0-1658106668030.png

The model:

vbinbinyumsft_1-1658106685754.png

 

2.Create a table visual, and create a measure

Shipment =
VAR cur_date =
    MAX ( 'Table 4'[Dates] )
VAR pre_date =
    CALCULATE (
        MAX ( 'Table 4'[Dates] ),
        FILTER ( ALL ( 'Table 4' ), 'Table 4'[Dates] < cur_date )
    )
VAR temp_table =
    CALCULATETABLE (
        'Table 3',
        'Table 3'[Date] <= cur_date
            && 'Table 3'[Date] >= pre_date
    )
RETURN
    CALCULATE ( [sum_purchase], temp_table )

vbinbinyumsft_2-1658106758658.png

 


If I misunderstand your demands, please feel free to let me know.


Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Luis98 Not 100% following, what are the expected results from the sample data?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Sorry @Greg_Deckler , I just see that the table is not okay.

 

My table´s purchase has the following structure:

 

Date

 

Purchase

2022/01/05 706
2022/01/10 1,312
2022/01/22 806
2022/01/27 210
2022/02/02 1,037
2022/02/10 1,808
2022/02/17 1,311
2022/02/25 1,793
2022/03/03 1,500

 

And I want to get the next table: 

Dates

 

Shipment

2022/01/15 2,018
2022/02/01 1,016
2022/02/15 2,845
2022/03/01 3,104
2022/03/15 1,500

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors