Propagating filters using TREATAS in DAX

  Рет қаралды 44,123

SQLBI

SQLBI

Күн бұрын

How to create a virtual relationship in DAX using the TREATAS function. Article and download: sql.bi/41311/?aff=yt
How to learn DAX: www.sqlbi.com/guides/dax/?aff=yt
The definitive guide to DAX: www.sqlbi.com/books/the-defin...

Пікірлер: 60
@DIGITAL_COOKING
@DIGITAL_COOKING 3 жыл бұрын
Alberto you're the best teacher of DAX I ever seen
@Connor-kv5cm
@Connor-kv5cm 5 ай бұрын
don't usually comment but wanted to say a huge thanks for making these videos/ blog posts. You're the only channel delving into these abstract but critically important DAX issues. I see myself as an experienced data analyst but learn new and amazing things in your content every time. The thoroughness and the way you simply explain complex issues is just amazing
@SQLBI
@SQLBI 5 ай бұрын
Thank you!!
@Turbo_PilotSky
@Turbo_PilotSky 3 жыл бұрын
Hi Alberto, Thank you for your wonderful teaching and the videos that you create.
@ed2921
@ed2921 3 жыл бұрын
You guys make this stuff look easy. Nice work gents.
@paulosergiorocha2084
@paulosergiorocha2084 3 жыл бұрын
Very nice! Its always good to have choices on your sleeve.
@JohnSmith-rx2uv
@JohnSmith-rx2uv 3 жыл бұрын
This really is one the best PBI videos I've ever seen! Wow I've been struggling to find ways to avoid bi directional relationships Thank you so much Alberto!
@lorentsnv
@lorentsnv 3 жыл бұрын
Awesome, thank you Alberto, again and again!! :-) Really appreciate that you share your huge knowledge, in a very consumable way!!
@dallasyount4072
@dallasyount4072 3 жыл бұрын
Excellent demonstration with examples of best solution based on model
@madanjoshi5004
@madanjoshi5004 2 жыл бұрын
You are amazing Alberto...
@ShabnamKhan-vk7fj
@ShabnamKhan-vk7fj 3 жыл бұрын
This is awesome, thanks so much Alberto!
@guilhemdelorme9089
@guilhemdelorme9089 3 жыл бұрын
Great explanation of TREATAS, thanks! I actually never did my homework on it and built my models so far with physical relationships that I deactivated when necessary, and leveraged USERELATIONSHIP ... Guess it was not a bad option performance-wise!
@SQLBI
@SQLBI 3 жыл бұрын
USERELATIONSHIP is better than TREATAS - you should use TREATAS when other approaches are not possible.
@joaquimcosta952
@joaquimcosta952 3 жыл бұрын
Very good like always. Thanks.
@ayushipahwa6497
@ayushipahwa6497 4 ай бұрын
🙌🙌
@Bharath_PBI
@Bharath_PBI 3 жыл бұрын
Thank you as always.. 🙂
@beginho2454
@beginho2454 2 жыл бұрын
Magical Function, like you... :)
@szpyrkowski
@szpyrkowski 2 жыл бұрын
great video
@kfirbar3928
@kfirbar3928 Жыл бұрын
Magic !
@aishwaryajose2997
@aishwaryajose2997 2 жыл бұрын
Another great video ! I am wondering though if the visual cross filters on a powerbi report would still work in the same manner using these virtual relationships in DAX ? is it not mandatory to have a physical relationship between tables for the powerbi visual cross filters to work ?
@chakrabmonoj
@chakrabmonoj 2 жыл бұрын
Alberto - I watch all your training videos with a lot of interest. In fact most of my dax I have learned from your website and also Marco Russo. The book by you both is never out of sight. I had a question though : Does it matter in which order the tables are linked in these functions - Treatas, Intersect or Contains? E.g. Would the dax still work if I wrote the Treatas code as : Treatas(Values(salesdetail[order number], salesheader[order number]? Does it have to be from the 1-side to the many-side (even though there is no explicit relationship here). I have a M-2-M situation and was wondering if any of these functions would work in that situation?
@adityaupadhyay3242
@adityaupadhyay3242 3 жыл бұрын
You make DAX look effortless. Best explanation of TREATAS. Do you have any video on ISFILTERED and ISCROSSFILTERED function?
@SQLBI
@SQLBI 3 жыл бұрын
They are certainly explained in our Mastering DAX video course. There is not much to say about those specific functions other than they are related the filter context propagation through relationships and expanded tables (which is the real topic to look for). You can also find useful content on DAX Guide: dax.guide/isfiltered/ dax.guide/iscrossfiltered/ This is the link to Mastering DAX: www.sqlbi.com/p/mastering-dax-video-course/
@UlverSK
@UlverSK 3 жыл бұрын
Thank you!
@deepakgupta3192
@deepakgupta3192 3 жыл бұрын
Hi Alberto thank you for this video, i have one request if you can make video on DATEADD using TREATAS dax , i am referring your Book, The Definitive Guide to DAX , and this DAX function m not so clear as what is happening here, in order to obtain the correct value. if you can explain better, will be a great help. Many thanks , Take care.
@arm1jo
@arm1jo 2 жыл бұрын
oh ALberto, you're god of dax )
@juancarlosfigueroafigueroa943
@juancarlosfigueroafigueroa943 Жыл бұрын
Hi Alberto need your help with a dumb problem? I have an order report published on a PBI app. A person can be first or second seller in an order and the report has RLS over the orders and linked to the seller code. My fact table has separate columns with first and second seller code. I just figured out that they can only see their first sales orders but I had a measure with their second seller orders wich they can't see due to the RLS auto filtering. I need your DAX magic! The second seller measure is a calculate with an ALL over salesman dimension table and a TREATAS with the actual seller code (VAR) to transform it to the second seller code.
@zxccxz164
@zxccxz164 4 ай бұрын
treatas is very confusing. Behind the scenes when you copy query you will see it used all over. But i rarely see it built into normal measures
@manohara3060
@manohara3060 Жыл бұрын
Hi I am using TREATAS Because I am not having unique value of the master table. Now I need to make filter in Master table. Please advise
@rashidkhan8161
@rashidkhan8161 Жыл бұрын
Hello, In power Bi, I have 2 excel files Jan-22 & Feb-22, each file contain 5 sheets sales, product , region, date & category, when I get 1 file and transform it all 5 sheets showing 5 queries separately, how can I combine feb-22 file in it and make it dynamically. Thanx
@Dims94
@Dims94 10 ай бұрын
Alberto- If I use a variable it doesn't give correct result, also which table should be in summarize, is there any direction of realtion that should be considered? test = var AdvertisingAmount = sum(Advertising[AdvertisingAmount]) VAR treatassales = CALCULATE ( AdvertisingAmount, TREATAS ( SUMMARIZE('Date', 'Date'[YearMonth]), 'Advertising'[YearMonth] ) ) RETURN treatassales
@ikar2k
@ikar2k Жыл бұрын
Alberto, thank you very much for the great video! You said it's bad practice to have a separate table with headers. What would you recommend to read or watch on this topic? Thank you in advance!
@ikar2k
@ikar2k Жыл бұрын
Yes, I have found it! 👍kzbin.info/www/bejne/iGm2kn2VlLqAfqs
@sbn4862
@sbn4862 2 жыл бұрын
I sae it again today, Treatas was too deficulat to andurstand to me in explanations with time itelegecy as sales previous month.Now i see it's more powerfull function
@forworkuseonly1388
@forworkuseonly1388 2 жыл бұрын
Hello, one question, circular dependency is the same as ambiguos? I'm a beginner. Thank!
@SQLBI
@SQLBI 2 жыл бұрын
No, look at the differences in these articles/videos: www.sqlbi.com/articles/bidirectional-relationships-and-ambiguity-in-dax/ www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/ www.sqlbi.com/articles/understanding-circular-dependencies/
@victorrivas7911
@victorrivas7911 3 жыл бұрын
Alberto, but TREATAS() inherits the lineage of both 'Date' and 'Product', wouldn't it create also ambiguity? As if there were physical relationships?. Or using TREATAS() give us the possibility to use both lineage at the same same, avoiding ambiguity?
@SQLBI
@SQLBI 3 жыл бұрын
Look at the answer to a similar question made by Paulo Sergio Rocha. The TREATAS creates a filter using two columns, when you propagate a filter through relationships you filter one column only in the target table and only one path of propagation can be used, not both.
@steinarbreivik1895
@steinarbreivik1895 2 жыл бұрын
How do you get from a working code in Dax Studio to a working measure in PowerBI Desktop? Is there another video that shows this? If I try to run a measure in Dax Studio without e.g SUMMARIZECOLUMNS it fails and if I try to run a measure in PowerBI Desktop including SUMMARIZECOLUMNS it fails there, so I'm kinda stuck between Dax Studio and PowerBI Desktop how you convert a working code in Dax Studio to PowerBI desktop
@SQLBI
@SQLBI 2 жыл бұрын
SUMMARIZECOLUMNS cannot be used in measures because it doesn't support context transition. See dax.guide/summarizecolumns/
@paulosergiorocha2084
@paulosergiorocha2084 3 жыл бұрын
Maestro Alberto, you said that if there was a physical relationship: Promotion[Category] -> Product[Category] Promotion[Year] - Date[Year] ... the Model would be *ambiguous* because there would be two different paths. (Let alone the repetition of the Year in Promotion[Year] - Many-Many) But when creating the Measure and use the Summarized table as a Filter in Calculate, aren't we doing a similar filter and then traversing the same two paths? Can you elaborate on that difference? Thanks!
@SQLBI
@SQLBI 3 жыл бұрын
The goal is to select a Promotion, which includes a specific combination of Year and Category. This would be the desired result if the relationship worked crossing the multiple paths in an AND condition, which is never the case. When there are multiple paths of filter propagation, only one can be used by the engine. Therefore, the SUMMARIZE creates a specific filter over two columns at the same time, producing the required result.
@paulosergiorocha2084
@paulosergiorocha2084 3 жыл бұрын
@@SQLBI Thanks Maestro!
@javedkhan-tz6fn
@javedkhan-tz6fn 3 жыл бұрын
I just love your videos.. thanks Alberto
@Wzxxx
@Wzxxx 2 жыл бұрын
I wish there was a one file/datebase with same data as in all movies on the channel so one can follow all exercises. Files at the end of article are different.
@SQLBI
@SQLBI 2 жыл бұрын
Depending on the video, small adjustments could be made - but we prefer to keep the file of the article as a reference to avoid confusion.
@BernatAgulloRosello
@BernatAgulloRosello 3 жыл бұрын
So summarize always keeps lineage? It's a bit confusing sometimes to indentify if your lineage is still there or not. It's there any reference to that in dax.guide?
@SQLBI
@SQLBI 3 жыл бұрын
In general, all the DAX functions keep the data lineage, unless the column is the result of a scalar expression. It is only for set functions (UNION/INTERSECT/EXCEPT) that specific conditions apply because each column can be the result of the manipulation of different columns/table. Describing the data lineage behavior for each function would require duplicating the same rules in many function, which would be of limited use.
@BernatAgulloRosello
@BernatAgulloRosello 3 жыл бұрын
@@SQLBI oh, I see! Thank you. So easy when I see it, so tough when I write it. Enjoying dax 😀
@EngTarek831
@EngTarek831 Жыл бұрын
where can i find the pbix file to try on same data structure ?
@SQLBI
@SQLBI Жыл бұрын
Use the link in the description.
@florentibus01
@florentibus01 3 жыл бұрын
Whenever you can't create a physical relationship you revert to a virtual relationship. I've been doing a lot of the latter lately.
@InnovateTechnology
@InnovateTechnology 3 жыл бұрын
Love your videos as always so I have a total different question: what is the make and model of your chair? Regards, Jørgen
@PeterKontogeorgis
@PeterKontogeorgis 3 жыл бұрын
I was just wondering the same actually. Could be a Herman Miller Aeron, but hard to tell from the small part that’s visible.
@SQLBI
@SQLBI 3 жыл бұрын
Correct - you can find all the details of Alberto's setup here: www.sqlbi.com/blog/alberto/2021/02/14/on-my-recording-gear/
@yekhtiari
@yekhtiari Жыл бұрын
I have faced a challenge that Treatas inside calculate does not work and needs calculatetable to return correct value.I checked the VALUES ( sales[CurrencyCode] ) and VALUES ( sales[SalesDate] ) are returning one record so context transition happens ,but i cannot understand why i need calculatetable inside Treatas to get the correct result (one row). define var tbl= TOPN ( 1, FILTER ( Sales, sales[SalesDate] > DATE(2022,08,01) ) ) evaluate ADDCOLUMNS ( tbl, "rate (wrong)", CALCULATE ( --SELECTEDVALUE( CurrencyExchange[ExchangeRate],error("more than one rate is provided")) countrows(CurrencyExchange) ,TREATAS ( (VALUES ( sales[CurrencyCode] )), CurrencyExchange[FromCurrency] ) ,TREATAS (( VALUES ( sales[SalesDate] )), CurrencyExchange[PK_Date] ), TREATAS ( { "usd" }, CurrencyExchange[ToCurrency] ) ) ,"rate (correct)", CALCULATE ( --SELECTEDVALUE( CurrencyExchange[ExchangeRate],error("more than one rate is provided")) countrows(CurrencyExchange) ,TREATAS ( calculatetable(VALUES ( sales[CurrencyCode] )), CurrencyExchange[FromCurrency] ) ,TREATAS (calculatetable( VALUES ( sales[SalesDate] )), CurrencyExchange[PK_Date] ), TREATAS ( { "usd" }, CurrencyExchange[ToCurrency] ) ) ) I
@manohara3060
@manohara3060 Жыл бұрын
=CALCULATETABLE ( SUMMARIZECOLUMNS ( LayoutGrouping[LayoutGrp], "A.Revenue", CALCULATE ( SUM ([BaseAmount1] ), TREATAS(VALUES(LayoutGrouping[AC Code]),SunData[Account Code]) ) ) ) This Query is not working.. please help me out
Optimizing nested iterators in DAX
17:31
SQLBI
Рет қаралды 20 М.
Understanding data lineage in DAX
18:14
SQLBI
Рет қаралды 29 М.
Despicable Me Fart Blaster
00:51
_vector_
Рет қаралды 23 МЛН
When to use KEEPFILTERS over iterators
18:56
SQLBI
Рет қаралды 47 М.
Introducing ALLSELECTED in DAX
14:07
SQLBI
Рет қаралды 14 М.
Bidirectional relationships and ambiguity
14:02
SQLBI
Рет қаралды 100 М.
EARLIER Function in DAX
15:46
Goodly
Рет қаралды 38 М.
Understanding context transition
18:25
SQLBI
Рет қаралды 65 М.
Using tuple syntax in DAX expressions
32:24
SQLBI
Рет қаралды 8 М.
Working With Virtual In-Memory Tables In Power BI Using DAX
9:01
Enterprise DNA
Рет қаралды 30 М.
Using GENERATE and ROW instead of ADDCOLUMNS in DAX
12:26
😱Хакер взломал зашифрованный ноутбук.
0:54
Последний Оплот Безопасности
Рет қаралды 973 М.
Cheapest gaming phone? 🤭 #miniphone #smartphone #iphone #fy
0:19
Pockify™
Рет қаралды 4,2 МЛН
Какой ноутбук взять для учёбы? #msi #rtx4090 #laptop #юмор #игровой #apple #shorts
0:18
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,8 МЛН
Что не так с раскладушками? #samsung #fold
0:42
Не шарю!
Рет қаралды 213 М.