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

Marked as spam. If you believe this is an error, submit an abuse report.

Hi all,,

 

my below post marked as spam, but it is not!

 

please your support:

 

https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-Dax-help-to-sum-amounts-within-...

 

Regards,

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

Hi @imjeed ,

I create a table as you mentioned.

vyilongmsft_0-1721111137090.png

Then I create a calculated column.

DateTime = 
'Table'[Date] & " " & 'Table'[Time]

vyilongmsft_1-1721111396676.png

Next I create another calculated column.

DateTime Difference =
DATEDIFF (
    CALCULATE (
        MIN ( 'Table'[DateTime] ),
        ALLEXCEPT ( 'Table', 'Table'[Category] )
    ),
    'Table'[DateTime],
    MINUTE
)

vyilongmsft_2-1721111601636.png

Measure = 
CALCULATE(
    SUM('Table'[Amount]),
    FILTER(
        ALLEXCEPT('Table', 'Table'[Category]),
        'Table'[DateTime Difference] <= 30
    )
)

vyilongmsft_3-1721111652466.png

Finally I create a new table and here is the DAX code.

Table 2 = 
SELECTCOLUMNS(
    'Table',
    "Category", 'Table'[Category],
    "Measure", 'Table'[Measure]
)

vyilongmsft_4-1721111755254.png

 

 

 

Best Regards

Yilong Zhou

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

4 REPLIES 4
v-yilong-msft
Community Support
Community Support

Hi @imjeed ,

I create a table as you mentioned.

vyilongmsft_0-1721111137090.png

Then I create a calculated column.

DateTime = 
'Table'[Date] & " " & 'Table'[Time]

vyilongmsft_1-1721111396676.png

Next I create another calculated column.

DateTime Difference =
DATEDIFF (
    CALCULATE (
        MIN ( 'Table'[DateTime] ),
        ALLEXCEPT ( 'Table', 'Table'[Category] )
    ),
    'Table'[DateTime],
    MINUTE
)

vyilongmsft_2-1721111601636.png

Measure = 
CALCULATE(
    SUM('Table'[Amount]),
    FILTER(
        ALLEXCEPT('Table', 'Table'[Category]),
        'Table'[DateTime Difference] <= 30
    )
)

vyilongmsft_3-1721111652466.png

Finally I create a new table and here is the DAX code.

Table 2 = 
SELECTCOLUMNS(
    'Table',
    "Category", 'Table'[Category],
    "Measure", 'Table'[Measure]
)

vyilongmsft_4-1721111755254.png

 

 

 

Best Regards

Yilong Zhou

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

imjeed
Frequent Visitor

Hi @ryan_mayu 

 

Thanks for your replay

 

row number 7 should not be included becuase it's more than 30 Min in same day

 

first transaction of category B is 1-2-2023 20:00

last transaction of category B is 1-2-2023 20:40

 

so the last transaction should not included becuase it's more than 30MIN

 

thanks in advnace again.

@imjeed 

then you can try this

 

Column =
VAR _start=CALCULATE(min('Table'[datetime]),ALLEXCEPT('Table','Table'[Category]))
return if (DATEDIFF(_start,'Table'[datetime],MINUTE)<=30,"y")
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@imjeed 

you can combine date time column

 

datetime = 'Table'[Date]+'Table'[Time]
 
then create another column
 
Column =
VAR _last=maxx(FILTER('Table','Table'[Category]=EARLIER('Table'[Category])&&'Table'[datetime]<EARLIER('Table'[datetime])),'Table'[datetime])
return if(ISBLANK(_last),"y",if(DATEDIFF(_last,'Table'[datetime],MINUTE)<=30,"y"))
 
11.PNG
 
then sum the amount and filter column to y




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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!

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.