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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pawelj795
Post Prodigy
Post Prodigy

Quickly DAX measure fix - Filter

Hi,
I want to slightly modify my measure.
Currently, it looks like that: 


Aging =

VAR ItemID = SELECTEDVALUE(WH_Invent_Trans[ItemID])

RETURN
DATEDIFF(MAXX(
FILTER(ALL(WH_Invent_Trans); WH_Invent_Trans[ItemID] = ItemID);
WH_Invent_Trans[Date Physical]);
TODAY()-1;DAY)
 
But I want add to this measure 2 conditions.
Firstly, It must be only TransType = 0 or = 9 (transtype is column in table WH_Invent_Trans with values from 0 to 9)
Secondly, QTY<>BLANK (it also column in table WH_Invent_Trans)

I would appreciate any ideas 🙂
1 ACCEPTED SOLUTION

hej @pawelj795 

 

W pliku ktory wyslales nie bylo tego obiektu wiec musiale go wylachys z formuly.

 

Zalaczylem plik z formua.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

 

View solution in original post

31 REPLIES 31

@Mariusz 
A czy przypadkiem ALL nie wyczyscilo tez innych filtrow powiazanych z data?
Gdyz dodanie tej ostatniej czesci z poprzedniego posta nie spowodowalo zadnych zmian.

Nie ma innej mozliwosci zamiany DATESYTD?

Hi @pawelj795 

 

Tak ALL( CalendarTable ) usunie wszystkie filtry z tej tabeli, mozesz to zmienic uzywajac imion column zamiast tabeli.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

@Mariusz 
Spróbowałem rozwiązania z innego posta odnośnie liczenia narastająco dla większej ilości niż rok.
Chciałem połączyć ją z twoją, ale nie do końca to zadziałało.
Może znajdziesz błąd.

1. Na początku stworzyłem nową tabele dat, bez żadnych relacji do innych tabel.

2. Następnie miara

Spoiler
VAR LastYearFirstDate =
IF(
SELECTEDVALUE('Calendar'[Year]) = BLANK();
DATE( YEAR(LASTDATE(WH_Invent_Trans[Date Physical] ) ) -1;1;1);
DATE(YEAR(
CALCULATE(
LASTDATE( WH_Invent_Trans[Date Physical] );
FILTER(DimDates; DimDates[Year] = SELECTEDVALUE('Calendar'[Year]) )
)
) -1; 1; 1)
)

VAR CurrentDate =
IF(
SELECTEDVALUE('Calendar'[Year]) = BLANK();
MAX(DimDates[Date]);
CALCULATE(
MAX(DimDates[Date]);
FILTER(DimDates; DimDates[Year] = SELECTEDVALUE('Calendar'[Year]) )
)
)

VAR _tbl=
FILTER(
GROUPBY(
CALCULATETABLE(
WH_Invent_Trans;
KEEPFILTERS(WH_Invent_Trans[TransType] IN {0;9} );
KEEPFILTERS(WH_Invent_Trans[QTY]<> BLANK() );
ALLEXCEPT(WH_Invent_Trans; WH_Invent_Trans[ItemID] )
);
WH_Invent_Trans[ItemID];
"@maxDate"; MAXX(CURRENTGROUP(); WH_Invent_Trans[Date Physical] )
);
VAR _days = DATEDIFF( [@maxDate]; TODAY() -1; DAY)
RETURN _days >= 0 && _days <=15
)
VAR _date = MAX(DimDates[Date])

RETURN
CALCULATE(
SUM(WH_Invent_Trans[Inventory Value EUR]);
TREATAS(
SUMMARIZE(_tbl;WH_Invent_Trans[ItemID]);WH_Invent_Trans[ItemID]);
FILTER(
ALLSELECTED(DimDates);
DimDates[Date] >= LastYearFirstDate
&& DimDates[Date] <= CurrentDate
)
)

@Mariusz 
Ok, juz działa.
Był drobny błąd w znaku, powinien być >= zamiast =<.

Mam natomiast jeszcze jedną kwestię.
Muszę policzyć również wartość itemów, które nie miały od 1.1.2019 TransType 0 lub 9. -> czyli te wykluczone z miary,

ale jednocześnie, żeby się nie dublowały z wartością uwzględnioną w wiekowaniu.


Jest to zrobione w tym celu, żeby całkowita wartość wiekowania magazynu była zgodna z prawdą.

Jak to moge zrobic?

 

 

Hi @pawelj795 

You can not use variable or && as a CALCULATE filter argument.

 

Can you create a small data sample and explain the result? seeing data and expected result always helps.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

 

@Mariusz 
I must combine results from first measure you fixed as filter to my YTD calculation.

In meantime, I prepare some sample data.

Do you mind write in Polish? 
It would be much easier to explain 😉

Hi @pawelj795 

 

Sure we can try in Polish

 

Thanks 

Mariusz

@Mariusz 

Tłumacząc najprościej, chciałbym policzyć wiekowanie stanów magazynowych na wczoraj dla każdego przedmiotu (itemu) na podstawie daty przyjęcia.
Bardzo ważną kwestią jest to, że dla każdego przedziału wiekowania musi być oddzielna miara z przedziałem, tzn:
1. Miara (0,15 dni

2. Miara (16,30 dni itd ...


Z tym, że do policzonego stanu magazynowego musi być brany wyłącznie określony typ transakcji (transtype 0,9).
Kolejny warunek to taki, że nie mogą być brane transakcje, których ilośc jest pusta (QTY<>blank).

Hej @pawelj795  // Pawel

 

zalaczylem plik z kalkulacja "M" zobacz czy to jest o co ci chdzi.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

@Mariusz 

 

Wydaje mi, że to może byc coś takiego 😉
Przetestuje na realnych danych i dam znac co wyszlo

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors