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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
BI_Noob
Frequent Visitor

Sum Aggregated Values With Multiple Filters based on Dynamic Range

 
Please Help

I have a large dataset with sales information aggregated by date, store#, and most imporantly by hour. See Below

Date _ StoreId _ Hour _ Online Orders _ Phone Orders _ Total Orders
Jan 1 _ 1X _ 10AM _ 50 _ 100 _ 150

 

Essentially - I'm trying to create a column flag of T/F to identify when a store has 3 consecutive hours of Online sales = 0 but Total Orders were > X. 

=AND(SUMIFS(OnlineOrders,DATE,[@DATE],StoreId,[@StoreId],Hour,OR([@Hour],[@Hour]+1,[@Hour]-1)) = 0, SUMIFS(TotalOrders,DATE,[@DATE],StoreId,[@StoreId],Hour,OR([@Hour],[@Hour]+1,[@Hour]-1)) > X

 

Can someone please help?

5 REPLIES 5
v-chenwuz-msft
Community Support
Community Support

Hi @BI_Noob ,

 

The same result export by this DAX expression:

Column =
VAR _f =
    FILTER (
        'Table',
        [Date] = EARLIER ( 'Table'[Date] )
            && [StoreId] = EARLIER ( 'Table'[StoreId] )
            && [Hour]
                >= EARLIER ( 'Table'[Hour] ) - 1
            && [Hour]
                <= EARLIER ( 'Table'[Hour] ) + 1
    )
RETURN
    AND ( SUMX ( _f, [Online Orders] ) = 0, SUMX ( _f, [Phone Orders] ) > 0 )

 

vchenwuzmsft_0-1651633747517.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

amitchandak
Super User
Super User

@BI_Noob , need a better sample. I think it same as Continuous streak : https://youtu.be/GdMcwvdwr0o

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amit, 

I watched the video and I'm not too sure if it's the same. Attached you'll find a sample dataset. Here's how I got the column to calc what I'm trying to accomplish

 

Screen Shot 2022-04-29 at 1.11.34 AM.png

 

=AND(SUM(SUMIFS([Online Orders],[Date],[@Date],[StoreId],[@StoreId],[Hour],[@Hour]),SUMIFS([Online Orders],[Date],[@Date],[StoreId],[@StoreId],[Hour],[@Hour]+1),SUMIFS([Online Orders],[Date],[@Date],[StoreId],[@StoreId],[Hour],[@Hour]-1)) = 0,
SUM(SUMIFS([Phone Orders],[Date],[@Date],[StoreId],[@StoreId],[Hour],[@Hour]),SUMIFS([Phone Orders],[Date],[@Date],[StoreId],[@StoreId],[Hour],[@Hour]+1),SUMIFS([Phone Orders],[Date],[@Date],[StoreId],[@StoreId],[Hour],[@Hour]-1)) > 0)

@BI_Noob , Please provide the same in table format. So that I can try.  Copy paste from excel.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amit,

Please see below;

Sample Dataset 

Sorry copy and paste from excel causes an error so I had to create link to file. Let me know if this helps explain. I sincerely appreciate your help.

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.