Forum Discussion
ALL function with text
- 1 year ago
FBergamaschi This is solution provided by copilot. It seams to work.
I dont know if there is need to siplify it but here it is.VAR SummaryTable =CALCULATETABLE(SUMMARIZE(FILTER('Stock adjustment data','Stock adjustment data'[Physical Inventory Status] = "POST"),'Product information'[Product],"TotalDiff", SUM('Stock adjustment data'[Difference Quantity(PIC)])),REMOVEFILTERS('Calendar'[Date]), // ⬅️ This removes the impact of the date slicerALL('Stock adjustment data'))VAR CurrentProduct =SELECTEDVALUE('Product information'[Product])VAR ProductTotal =CALCULATE(MAXX(FILTER(SummaryTable, [Product] = CurrentProduct),[TotalDiff]))RETURNIF(ISINSCOPE('Product information'[Product]),IF(ProductTotal < 0,CALCULATE(MINX(FILTER(SummaryTable, [Product] = CurrentProduct),[TotalDiff])),ProductTotal),SUMX(SummaryTable, [TotalDiff]) // ⬅️ Subtotal logic)
You need to specify the codition you want those column to fulfill, for example:
CALCULATE(
SUM('Stock adjustment data'[Difference Quantity(PIC)]),
ALL('Calendar'[Date]),
'Stock adjustment data'[Physical Inventory Procedure] ="Value1",
'Stock adjustment data'[Reason]="Value2"
)
or some other criteria (pls clarify so I can help)
If this helped, please consider giving kudos and mark as a solution
me in replies or I'll lose your thread
consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
FBergamaschi These are all the values in [Physical Incentory Procedure]:
AL
AS
HL
HS
And in [Reason]:
CCIV
LSPI
PTPI
STND
UNAS
UPLD
Do I have to list them all in the dax to make sure that it works?
- mdaatifraza55561 year agoSuper User
Hi Justas4478
No need to add all the values.
CALCULATE(
SUM('Stock adjustment data'[Difference Quantity(PIC)]),
ALL('Calendar'[Date]),
ALL('Stock adjustment data'[Physical Inventory Procedure]),
ALL('Stock adjustment data'[Reason])
)
If this answers your questions, kindly accept it as a solution and give kudos.- Justas44781 year agoPost Prodigy
mdaatifraza5556 I tired it but it still returns different results when you filter.
The value circled in red is what I am hoping would be always shown.
And I would hope it would be same result in all rows in that column- FBergamaschi1 year agoSuper User
CALCULATE(
SUM('Stock adjustment data'[Difference Quantity(PIC)]),
REMOVEFILTERS('Calendar'[Date]),
REMOVEFILTERS('Stock adjustment data')
)
in this eay you remove all the filters, let's see if that is OK or you need to preserve some and we will fix itIf this helped, please consider giving kudos and mark as a solution
me in replies or I'll lose your thread
consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
- Justas44781 year agoPost Prodigy
mdaatifraza5556 I was thinking, maybe it needs to be summarized per product number and not sum to get outcom I am aiming for
- FBergamaschi1 year agoSuper User
That depends on what you want to impose on those columns?
You want to allow only some values (which?) or you wanto to remove the filters form thos columns? Please explain and I shall provide the code
If this helped, please consider giving kudos and mark as a solution
me in replies or I'll lose your thread
consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI