Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

DAX: SubFigure logic to cater priority on date slicer first, then group by columns to sum qty

Hi friends,

I need the subtotal based on grouping included date filtering applied at first.

Priority: 1: date slicer filtering

             2: sort by Ckey, ItemNo, DB_Ind, Entry No

             3: group by Ckey, ItemNo

             4: sum qty for inventory OUT only

But currently logic only able cater for item 2,3,4.


The first screen showing sample of raw data about overall inventory including inventory IN & inventory OUT.
inventory IN: Entry Type in {0,2,6}               inventory OUT: Entry Type in {1,3,5}



Screen below is what currently I can get the correct result by applying below logic.

InventoryOUTQty = 
SUMMARIZE(FILTER(V_ItemLedgerEntry,V_ItemLedgerEntry[EntryType] in {1,3,5}),"InventoryOUT",SUM(V_ItemLedgerEntry[InvoiceQty]))
Subtotal_InvOUTQty =
CALCULATE([InventoryOUTQty],ALLEXCEPT(V_ItemLedgerEntry,V_ItemLedgerEntry[CKey],V_ItemLedgerEntry[Item No_]))


Btw, I cant get the result below if date slicer is selected, it still showing overall subtotal as -26 instead of -1.



Thank you.



Super User
Super User

I am not sure I follow. You say you are getting the correct result. So that's good right? 


It sort of sounds like a measures total issue to me but that's a complete guess. This looks like a measure totals problem. Very common. See my post about it here:

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:

@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

Hi Mr. Greg,


Yes, I am getting correct subfigure if no filter for date slicer (default showing all record). But if do some selection on date slicer, the subfigure will be wrong because it still showing grouping based on all record instead of record after applied date slicer filtering.


Thank you.

Xio Fen

Helpful resources

June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors