DAX Fridays #12: SUM of distinct values

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ธ.ค. 2024

ความคิดเห็น • 172

  • @roirihany8825
    @roirihany8825 4 ปีที่แล้ว +12

    You can use calculate and use one measure
    Sumx(distinct(aaa), calculate( max (bbb) )

    • @mercspalms9672
      @mercspalms9672 8 หลายเดือนก่อน

      You saved my life, your an Angel!! Ive been doing a sum formula outside of my pivot table and needed to automated the process. I tried the method in this video but i think its outdated and was not working. this did and im sooo happy. you made my job easier.

    • @patwaripiyush
      @patwaripiyush 8 หลายเดือนก่อน

      This is amazing

  • @VinayKumar-ij4eu
    @VinayKumar-ij4eu 3 ปีที่แล้ว

    Thanks Ruth!
    I use below mentioned two DAX and get the correct result , plz validate once :-
    1st Measure :- Distinct Sum =
    SUMX(DISTINCT('Budget Table'[PartDenom]),MAX('Budget Table'[Budget Cost Tooling]))
    2nd Measure :- Correct Distinct Sum =
    SUMX(DISTINCT('Budget Table'[PartDenom]),'Budget Table'[Distinct Sum])
    Thanks

    • @sabkabaap7206
      @sabkabaap7206 2 ปีที่แล้ว

      Just use calculate function to get max "budget cost tooling" for each distinct partdenom, which is then added since we are using sumx function:
      SUMX(DISTINCT('Budget Table'[PartDenom]),CALCULATE(MAX('Budget Table'[Budget Cost Tooling])))

  • @Victor-ol1lo
    @Victor-ol1lo 8 ปีที่แล้ว +1

    Hi Ruth, very interesting videos - Thumbs up !!. To have for every function a separate video is really helpful. Hope to see the EARLIER funciton in one of your next tutorials.

    • @CurbalEN
      @CurbalEN  8 ปีที่แล้ว

      +Victor Friesen Thanks Victor! I will do some videos on time intelligence first, but after that EALIER is next :)
      /Ruth

  • @reng7777
    @reng7777 4 ปีที่แล้ว +1

    Dear you have saved my life!!!! i was looking for something like this several weeks ago!!!! muak!!!

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      🥳🥳🥳
      /Ruth

    • @carolinabruno22
      @carolinabruno22 4 ปีที่แล้ว

      @@CurbalEN you saved my life as well!! thank you so much, amazing explanation!

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      @@carolinabruno22 🥳🥳🥳
      /Ruth

  • @eslamfahmy87
    @eslamfahmy87 หลายเดือนก่อน

    Actually, I loved your committee regarding your videos, and I really loved (Dax friday Playlist), but I think that you need to prepresent before you go live as something I stuck while the video working but still you one of the Dax heroes 😉

  • @vijaybodkhe8379
    @vijaybodkhe8379 2 ปีที่แล้ว

    Really appreciate your work of present failed scenarios and then moving to correct one..Thanks alot

  • @filipesantos891
    @filipesantos891 3 ปีที่แล้ว

    Thank you very much Ruth! I've strugling with this issue for days, now I can move on.

    • @CurbalEN
      @CurbalEN  3 ปีที่แล้ว +1

      Smooooooth

  • @georgigeorgiev1967
    @georgigeorgiev1967 3 ปีที่แล้ว +1

    Great job! At last, explaining exactly the issue I was experiencing in such a detailed manner! Bravo :)

    • @CurbalEN
      @CurbalEN  3 ปีที่แล้ว

      🥳🥳

  • @AjayKumarparmar
    @AjayKumarparmar 4 ปีที่แล้ว +1

    Hi Curbal. please answer my question... Why cannot be use CALCULATE with Values to sum unique values... CALCULATE(SUM(TOOLING COST)),VALUES(TOOLING COSTS)) ... My idea is in calculate , the second parameter is filter...so let us use values dax...so it will pick tooling costs without duplicates and then as per first criterial, it should be sum.....i thought this way but calculate does not seem to be working..it still picking all values....and not unique

  • @benfriger
    @benfriger 3 ปีที่แล้ว

    thanks so much Ruth, You're the perfect teacher.

  • @damianmarquith3741
    @damianmarquith3741 4 ปีที่แล้ว +1

    Ruth, I found this video and it is almost perfect. However, I have where my items can have the same cost. So in your example, if I added two more items, say, Casing 1 and Casing 2 and they have the same price ... what happens with your formula given, it only counts the single price for both, rather than two of the same price. Would you know how to improve this calculation where you can still sum the total without dropping out items with the same price? Thanks so much!

  • @thedavidgzz
    @thedavidgzz 2 ปีที่แล้ว

    mil gracias por tus tutoriales, me has salvado varias veces

    • @CurbalEN
      @CurbalEN  2 ปีที่แล้ว

      Todo un placer!

  • @r21061991
    @r21061991 3 ปีที่แล้ว

    Ruthlessly decimated the problem !!

    • @CurbalEN
      @CurbalEN  3 ปีที่แล้ว

      🤣 My parents knew what they were doing from the start!!

  • @osandrolucas
    @osandrolucas 4 ปีที่แล้ว

    You are incredible.
    Im so sad, because the people of my job are changing the power bi to tableau....
    But, thanks for all!!! I learning to much about power bi, and you help me to much.
    thanks thanks thanks

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว +1

      Thanks for your feedback and enjoy tableau, I heard it is a great visualization tool and has a great community too. You are going to learn a lot and are in for a treat :)

  • @kaoutermiguil
    @kaoutermiguil ปีที่แล้ว

    You saved my life with this

  • @9323793901
    @9323793901 ปีที่แล้ว

    Thanks dear from last 2 days i was searching for this solution :)

  • @cesarrenatobarretofernande5940
    @cesarrenatobarretofernande5940 6 ปีที่แล้ว +2

    Thanks for amazing video! So, I have a question. Why it´s different working with an outside measure using "max" that using it inside of the mean measure? Thanks in advance!

    • @daniel.balandra
      @daniel.balandra 5 ปีที่แล้ว

      I have the same question...? :(

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว

      I have to check the video to understand the question and my time is soooo limited... I will try on Monday.

    • @islamelhawary6679
      @islamelhawary6679 4 ปีที่แล้ว

      @@CurbalEN I've the same question

    • @ukaszk4410
      @ukaszk4410 2 ปีที่แล้ว

      @@islamelhawary6679 I am not sure if it worked in 2016 when the video was posted, but you can write it in one measure as follows:
      Measure =
      SUMX (
      SUMMARIZE (
      'Table',
      'Table'[PartDenom],
      'Table'[Budget Cost Tooling]
      ),
      'Table'[Budget Cost Tooling]
      )

  • @MrJonjoe1977
    @MrJonjoe1977 2 ปีที่แล้ว

    I've been stuck trying to do something very similar for hours. I owe you a 🍺

    • @CurbalEN
      @CurbalEN  2 ปีที่แล้ว

      I could use one right now ;)

  • @chavelooo33
    @chavelooo33 4 ปีที่แล้ว

    Excellent video, not only for the technical concepts also for sharing your personal learning experiece.

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว +1

      Thanks !

  • @joanneosborne2428
    @joanneosborne2428 4 ปีที่แล้ว

    This is a great explanation. Thanks, Ruth.

  • @shaminisridaran4898
    @shaminisridaran4898 3 ปีที่แล้ว

    owh my.. thanks for the video. Been struggling to get this right. Thanks again ! Will continue to subscribe and watch you other videos.

    • @CurbalEN
      @CurbalEN  3 ปีที่แล้ว

      Glad it was helpful!

  • @Fox252-e2p
    @Fox252-e2p 2 ปีที่แล้ว

    Awesome! Thank you for the solution and, more importantly, the explanation of the calc

  • @chiranjivikumar3690
    @chiranjivikumar3690 3 ปีที่แล้ว +1

    SUMX(DISTINCT('Table'[partdenom]),SUM('Table'[Budge cost toling])/COUNT('Table'[partdenom]))
    we can use this simple

  • @SOURCEOFFICIELLE
    @SOURCEOFFICIELLE 4 ปีที่แล้ว

    would a variable that holds max of each tool would work ? instead of a measure that's referenced later ?

  • @ricardotito6072
    @ricardotito6072 7 ปีที่แล้ว +2

    Very good! a query, from the example if I want to count all the different numbers, what dax function would you use?
    Example: Band = 1, Casing = 1, Mechanis = 1, Screw = 0.
    Thank you

    • @CurbalEN
      @CurbalEN  7 ปีที่แล้ว

      +Ricardo Tito Hi Ricardo,
      Not sure what you mean, but I have a count video that might help you?
      m.th-cam.com/video/V8wYTjKyvgk/w-d-xo.html
      /Ruth

  • @AlejandraLemmo
    @AlejandraLemmo 5 ปีที่แล้ว

    No hay dudas, cada vez que tengo una duda, acudo aquí y pam, se soluciona. Gracias

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว

      Muchas gracias por el feedback :)
      /Ruth

  • @clairejsquibb
    @clairejsquibb 2 ปีที่แล้ว

    Thanks so much - I'm fairly new to DAX and this has exactly addressed a problem I had.

    • @CurbalEN
      @CurbalEN  2 ปีที่แล้ว

      Fabulous!!

    • @clairejsquibb
      @clairejsquibb 2 ปีที่แล้ว

      Your explanation was particularly useful, as it showed me how to see what is going on with the filter context. Also, I had started off with exactly the first two error stages, so you showed me where I had gone wrong - and the answer was so much simpler than I expected! I had been searching for ages, and found all kinds of really advanced "solutions" that I couldn't get working, then you did it all with MAX and SUMX!

  • @briantey6997
    @briantey6997 3 ปีที่แล้ว

    Hi. I dont really understand , why when sumx(distinct(table),max(column)) cant success, but when we write a measure outside for abc=max(column) and then sumx(distinct(table),abc), it will work?

  • @matussumilas
    @matussumilas 3 ปีที่แล้ว +1

    GREAT explanation. Exactly what I was looking for. Is it possible to save Max Tooling Cost as variable in the formula or it has to be as new measure only?

  • @genivalsantos6630
    @genivalsantos6630 4 ปีที่แล้ว

    Very good!!
    Simple but fantastic!!
    Congratulations

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว +1

      Great to hear!

    • @genivalsantos6630
      @genivalsantos6630 4 ปีที่แล้ว

      @@CurbalEN
      I'm brazilian. I need to improve my English. I love your classes.

  • @AjayKumarparmar
    @AjayKumarparmar 4 ปีที่แล้ว

    in a hope that you reply to my question.....i again repeat...why cannot we use calculate using values here in a table which does not have any filter...CALCULATE(SUM(TOOLING COST)),VALUES(TOOLING COSTS))

  • @biswanathdas5029
    @biswanathdas5029 3 ปีที่แล้ว

    Thanks....I was stuck at this for two days....

  • @cristobalsalcedo5642
    @cristobalsalcedo5642 3 ปีที่แล้ว

    Thank you so much, what a good video, but why doesn't it work for me when there are many blank values?

  • @rkavitha1
    @rkavitha1 3 ปีที่แล้ว

    Hi, Thanks for the video, finally I was able to work around. But, I am having one issue. Even though sumx function and Max function gives correct values in each rows, the visual total is different. Any help with that..

  • @amadorcamacho
    @amadorcamacho 4 ปีที่แล้ว

    I was trying all day how to do it, thanks. and thanks for curbal Data Labs too.

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      My pleasure :)
      /Ruth

  • @lavanisari
    @lavanisari 4 ปีที่แล้ว

    Thank you so much Ruth!! I am new to powerBI and struggles with this for an entire day before I could find this video! many many thanks! Subscribed to your channel now :0 I have seen a few other videos of your too and they are awesome!!

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      Welcome and I hope more videos will be useful to you!

    • @lavanisari
      @lavanisari 4 ปีที่แล้ว

      @@CurbalEN -- Thank you ! I needed to do average next of the same distinct fields and I did averagex function - averagex(table(field),maxmeasure ) but now My average is off...any thoughts on what I am missing?

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      @@lavanisari so many things it could be...share all the details with the power bi community to get personalized help!

  • @madiakns
    @madiakns 4 ปีที่แล้ว

    Thanks for this video Ruth... I was looking for this solution for a long time.

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      Just on time ;)
      /Ruth

  • @pathebah7426
    @pathebah7426 4 ปีที่แล้ว

    Thanks for another excellent video.
    I tried your formula, but using a variable for Max of tooling cost instead of a separate measure, and it doesn't work. Do you know why?

  • @sureshsonti8464
    @sureshsonti8464 6 ปีที่แล้ว +1

    Great video. This video just solved my problem. Thanks Ruth

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Perfect and have a great sunday!!
      /Ruth

    • @tusharagarwal9865
      @tusharagarwal9865 6 ปีที่แล้ว +1

      I am still not getting the correct result!!!! (None of them worked.... getting total wrong)
      MaxSales = max('TA tele_cascade'[Sales Calls])
      Total_Sales Calls =SUMX ( distinct('TA tele_cascade'[Agent] ) ,[MaxSales] )
      *********************************************************************************************
      Total_Sales Calls =
      SUMX ( Distinct ( 'TA tele_cascade'[Agent] ) ,CALCULATE ( MAX ( 'TA tele_cascade'[Sales Calls] ) ) )

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Post your case in the power bi community and make sure you give some sample data.
      /Ruth

  • @cokebarra3610
    @cokebarra3610 6 ปีที่แล้ว +1

    Hi Ruth, nice video. but I just feel abit confused:
    I dont understand correct distinct sum measure is working but max sum of tool cost measure is not. To me they are exactly the same as [max tooling costs] you are using is just an expression of the second part in max sum of toolcost measure...

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Hi, I have to watch that video again, but I am guessing that it is all about the filters that are applied on the first and the second measure.
      Maybe I can do a new video about it.
      /Ruth

    • @brunof.s.8186
      @brunof.s.8186 6 ปีที่แล้ว

      Hey Ruth, i have the exact some doubt as Super D Cinema. For me there is no difference writing the formula (MAX...) or put the measure as it is... isn't the same in a CALCULATE? For instance: CALCULATE(SUM(SALES[Sales Total]).... or CALCULATE([measure that represents the SUM OF SALES Total]);;;;
      Your videos are great.
      Cheers from Brazil!

    • @SyedUsman
      @SyedUsman 6 ปีที่แล้ว +1

      Measures have an implicit calculate that helps evaluate the row context.. thats y the measue max total cost works and the max(total cost) not work.

    • @lovemoregumbo8544
      @lovemoregumbo8544 5 ปีที่แล้ว

      I had the same thoughts. Power Bi is very strange. Max measure works, however, writing the actual formula MAX(Table1[Budget Cost Tooling] does not work in the measure called 'Max sum of tooling. very confusing. but great video.

    • @AjayKumarparmar
      @AjayKumarparmar 4 ปีที่แล้ว +1

      MAX is a aggregte function , it does calculation on entire column instead row wise. So, if you have A = 10 , B= 20, C = 40 , C = 70 ...using max on numbers will give you 70 . So, this means if you say i need a table using VALUES Dax, which removes the duplicates , your table would look like this ..A = 70, B = 70 , C = 70 .....So, now you see you have no duplicates (c item is coming twice in a table) and corresponding values to each of these items is 70. Why? Because MAX worked on entire list or columns of prices 10,20,40, 70 and came out with 70 as biggest number. So, when you supply this table to SUMX which we use to add is going to add 70 thrice and giving you 70*3 = 210 . Which is obviously wrong because we wanted the maximum value basis each item and not just the one largest number from column. So, we go and wrap around our MAX with CALCULATE. Why? because calculate has a flexibility that it works on filter context, if you see its definition. Now since max is a part of CALCULATE, It will return maximum values only by looking at the item which you have put in VALUES Dax. So, VALUES(PRICE) is returning unique items like A,B,C and against these items, CALCULATE(MAX) now giving maximim value basis item . So, it has now A = 10, B = 20 , C = 70 ..this is finally used in SUMX so we have a correct answer.. Calculate always takes care of filters which are availble in table. So you have now maximum value basis filters which are A,B,C

  • @duydiep3909
    @duydiep3909 7 ปีที่แล้ว +1

    Thank you so much! it's very helpful.
    If the value in the third row of column Budget cost tooling is 50 and the value in the fifth row of column Budget cost tooling is 100. How do we make sum total on PartDenom.
    Thanks alot

    • @CurbalEN
      @CurbalEN  7 ปีที่แล้ว +1

      +Duy Diep Hi Duy, not sure what you mean, can you explain a bit more?
      /Ruth

    • @duydiep3909
      @duydiep3909 7 ปีที่แล้ว

      Thanks Ruth, I think i figured out it, In your measure just chose the right distinct column we want. anyway thanks alot

  • @deepakkanade5041
    @deepakkanade5041 5 ปีที่แล้ว

    Great 'drill down' explanation of each function.

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว

      Thanks Deepak!
      /Ruth

  • @annaathi5741
    @annaathi5741 6 ปีที่แล้ว +1

    Is there a way to get this done in one step, instead of two additional measures.
    I have a case where I need to fix sum of distinct values for about 500 measures. If this is two step, process, I have to additionally create another 1000 columns.
    I bet there should be a way to do this with one additional measure

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Hi Anna,
      There are always many ways to do the same thing in DAX. To know what is best for your model , post sample data in the power bi community to get detailed help.
      Have a great weekend!
      /Ruth

    • @annaathi5741
      @annaathi5741 6 ปีที่แล้ว +1

      Thanks Ruth

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Have a great weekend Anna :)
      /Ruth

    • @AHMEDALDAFAAE1
      @AHMEDALDAFAAE1 5 ปีที่แล้ว

      You can use this UniqSum = Divide (sum(table [Part] ), counta (table [part]) ) and replace sum with sumx for iteration purpose

  • @matthewsharpe7398
    @matthewsharpe7398 3 ปีที่แล้ว

    Thank you!!! Just what I needed :)

  • @ABHISHEKGAUTAM062
    @ABHISHEKGAUTAM062 8 ปีที่แล้ว +1

    Can we achieve the sum of distinct values through any other way as SUMX() does not work in Direct Query option of Power BI?

    • @CurbalEN
      @CurbalEN  8 ปีที่แล้ว

      Hi Abhishek,
      SUMX will work with Direct Query if you make the following change in your Power BI Desktop file:
      File -> Options and then Settings -> Options -> Direct Query ->Allow unrestricted measures in Direct Query mode.
      /Ruth

  • @shahabhaidar243
    @shahabhaidar243 4 ปีที่แล้ว

    Hi Ruth,
    Is there any way to get the same result without using SUMX ?
    I'm working on a project where i have the same scenario. I have to calculate the SUM of Distinct values. i used the method which is shown in this video and that really works also but since my data is really huge the SUMX calculation is causing it slowdown.
    I'm facing this problem since last week. tried searching on internet and found several references to Distinct count calculations, but none seems to give me the result that I require.

  • @lenzypetty1097
    @lenzypetty1097 6 ปีที่แล้ว

    Thank You!!!!!!!! This video helped me build a Power BI measure that would be equivalent to a Tableau Level of Detail Calculation. Thanks so much!

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Yey!!! Glad it helped :)
      /Ruth

  • @annarohacewicz8190
    @annarohacewicz8190 3 ปีที่แล้ว

    Thank you a lot, Ruth. I have a question though. I understand totals, but I didn´t get why in max sum of toolcost we have a correct values in the filter (in visualizations). I mean, shouldn´t it be 1234 for every row in the visualization? Thank you.

  • @opod84
    @opod84 7 ปีที่แล้ว +2

    Thank you for demystifying this!

    • @CurbalEN
      @CurbalEN  7 ปีที่แล้ว

      +David Ocampo You welcome!! :)
      /Ruth

  • @albertmartinez7421
    @albertmartinez7421 3 ปีที่แล้ว

    Very well put together. Thank you.

  • @Jbrenn46
    @Jbrenn46 6 ปีที่แล้ว +1

    What screen recording software are you using, the quality is fantastic

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Thanks Justin, Camtasia 8 :)
      /Ruth

  • @CloudhoundCoUk
    @CloudhoundCoUk 8 ปีที่แล้ว +2

    Yet another fabulous video.

    • @CurbalEN
      @CurbalEN  8 ปีที่แล้ว

      +Cloud Hound Thanks Christopher for your comment and all the shares! Truly appreciate it :)
      /Ruth

    • @rupasingh3366
      @rupasingh3366 6 ปีที่แล้ว

      Cloud Hound ,

  • @edwardsheats7453
    @edwardsheats7453 5 ปีที่แล้ว

    Fantastic video, and loved the detailed explanation throughout the process!

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว

      Thanks Edward!
      /Ruth

  • @mathijs9365
    @mathijs9365 7 ปีที่แล้ว +3

    I really dont understand it.Distinct means it gives the column of unique values. But then it sums it up like there is no distinct. Using the Max function seems like a workaround.

  • @NorbertoVeraReatigaNVR
    @NorbertoVeraReatigaNVR 8 ปีที่แล้ว +1

    Gracias!!! Ruth trabajare en este interesante planteamiento...

    • @CurbalEN
      @CurbalEN  8 ปีที่แล้ว

      +Norberto Vera Reatiga Curioso que algo tan sencillo teóricamente, sea tan complicado, verdad?
      /Ruth

  • @antipghosh
    @antipghosh 2 ปีที่แล้ว

    How to do summation of first n numbers in a series??? Any idea?
    Series: { 1, 3, 6, 11, 17, 2, 8}
    Desired Sum of first 3 numbers: 1+3+6
    How to do this in power bi

  • @chamanihome6580
    @chamanihome6580 3 ปีที่แล้ว

    Nice and Well explained

  • @safifaruqi
    @safifaruqi 4 ปีที่แล้ว

    I am sorry but I am totally lost still... If I want to do a simple sum, I have to still add distinct and evaluate and max statement to get one calculation? I dont get it.

  • @annarocha9769
    @annarocha9769 ปีที่แล้ว

    You saved meeee thanks a lot for this!!!

  • @mohitchhabra5390
    @mohitchhabra5390 6 ปีที่แล้ว +1

    Hey Ruth,
    This one is really appreciated...
    I am also looking for 95% Confidence interval band visualization... any suggestion ??
    Thanks for help !!
    Mohit.

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      I dont have a video on that, but check the power bi community , I am sure somebody must have done something similiar and can give your some pointers!
      /Ruth

  • @JP-dt8em
    @JP-dt8em 4 ปีที่แล้ว

    Is there any other solution without using SUMX
    Because SUMX is very slow

  • @taam232
    @taam232 2 ปีที่แล้ว

    I had to wait a lot till I get the right dax, why you didn't start with the right one from the beginning ?

    • @CurbalEN
      @CurbalEN  2 ปีที่แล้ว

      “Tell me and I forget,
      teach me and I remember” - Benjamin Franklin

  • @denpries
    @denpries 6 ปีที่แล้ว +2

    First of all: Ruth i hope you are doing fine again after your head injury!
    Secondly: Oh my god i just had 1.5 hour worth of reaction typed out and chrome crashed :D
    Thirdly: Ruth, can you please please please always refer to contexts in these cases? Cant say it enough but its vital for many people to develop a sense of really understanding. I also still struggle.
    Anyway. I give it a try. And i could even still be wrong, as context differentiation is a bit of a hassle :P
    distinct = sumx(DISTINCT(Table1[type]);max(Table1[cost]))
    is totally not the same as
    distinct2 = SUMX(DISTINCT(Table1[type]);[maxcost])
    where [maxcost] = max(Table1[cost])
    Which you correctly demonstrated in the video. However, you did not say why this was the case and this is one of the most confusing things out there. Because they really look to do the same thing.
    The reason is that a measure implicitly adds a nested calculate().
    distinct3 = SUMX(DISTINCT(Table1[type]);CALCULATE(max(Table1[cost])))
    In turn, this is in this example the same as:
    distinct4 = SUMX(DISTINCT(Table1[type]);CALCULATE(max(Table1[cost]);FILTER(ALLSELECTED(Table1);EARLIER(Table1[type])=Table1[type])))
    So what happens? Lets check the calculate() part first.
    With max(table1[cost]) you literlly ask for the maximum of all rows with the filter context that is shown in argument 2 of the calculate function.
    This filtercontext is dictated with the filter() function. Filter() selects all rows from the filter context allselected(). The filter(allselected(...)) is not even really needed here as the 2nd part of sumx already (implicitly again) did this, but for completeness sake: it disregards any column and row filters. So basically you end up with the complete dataset unless you have put a sneaky slicer somewhere that we dont know about.
    Then, you select from the entire filterset only those rows where the type (e.g. 'band') matches the iterator. Lets take a closer look. We basically have 2 parts within the filter() function. Note that within the filter we are in ROW context. So only one row at a time.
    (A) EARLIER(Table1[type]) = (B) Table1[type]
    The first part is about the context BEFORE the whole filter(allselect()) context. So basically the iterated item.
    The second part is IN the row context as this is part of the filter. It contains all rows
    Then it functions like:
    1- For every unique item (distinctcount)
    2- Calculate the maximum value...
    2b- For all rows in the current table context filter(allselected(...);
    2c But only when the rows of this context match the value as given by the iterator
    So in the total set, the context is determined for every unique item in the iteration, then the maximum is determined, and you add it to the total for every unique item.
    This in contrast to:
    distinct = sumx(DISTINCT(Table1[type]);max(Table1[cost]))
    Which basically does:
    1- For every unique item (distinctcount)
    2- Return the maximum value from the table context
    So in the total set, the table context is full set, and you add it to the total for every unique item.
    *still confused :P

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Hi Dennis, feeling perfect thanks!
      Could you post the question in the power bi community? Curbal is on vacation now :)
      /Ruth

    • @denpries
      @denpries 6 ปีที่แล้ว +2

      It was a long read. I know that. But it definately was not a question. It was an answer on a question from a user on your post which i addressed, plus a remark to you :)

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Oh, in that case, thanks!!
      I am on vacation mode :)
      /Ruth

    • @denpries
      @denpries 6 ปีที่แล้ว +1

      Put awaaaaaaaayyyy the phoneeee

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      😂😂

  • @Yoho696
    @Yoho696 3 ปีที่แล้ว

    Very well explained, thanks! I have a question. I'm using this (and it works), but I want to use this in combination with calculate and the All function. This all function does not work with this unfortunately. And I really can't find why not. Do you have a solution?
    Thanks in advance and keep up the good work!

  • @islamelhawary6679
    @islamelhawary6679 4 ปีที่แล้ว

    we can use this measure too: SUMX(DISTINCT(Table1[PartDenom]),CALCULATE(MAXX(Table1,Table1[Budget Cost Tooling])))

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว +1

      Thanks for sharing!
      /Ruth

    • @francisdjamba7550
      @francisdjamba7550 4 ปีที่แล้ว

      @@CurbalEN very nice my dear thanks so much

    • @AjayKumarparmar
      @AjayKumarparmar 4 ปีที่แล้ว

      Can you explain This step by step...if Max is used it should return One value only...if I want total of each item but only their max value should sum

  • @EeDen0910
    @EeDen0910 5 ปีที่แล้ว

    Thank you for the detailed explanation!

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว

      🎉🎉
      /Ruth

  • @nikhilchenna
    @nikhilchenna 2 ปีที่แล้ว

    Thank you so much ❤

  • @adnanhajabubaker4158
    @adnanhajabubaker4158 6 ปีที่แล้ว +1

    Many thanks, I really tired to fid correct formula, appreciate

  • @PlanetaAtemporal
    @PlanetaAtemporal 3 ปีที่แล้ว

    Very good!

  • @somidiytheory6493
    @somidiytheory6493 5 ปีที่แล้ว

    you save my day

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว

      Music to my ears 😊
      /Ruth

  • @dogsaviour7911
    @dogsaviour7911 2 ปีที่แล้ว

    Thanks you solved my problem

  • @qungu7251
    @qungu7251 4 ปีที่แล้ว

    the Max measure which list the max cost could be Max or distinct, the result is the same

  • @AHMEDALDAFAAE1
    @AHMEDALDAFAAE1 5 ปีที่แล้ว

    I got another way to solve the problem UniqSum = Divide (sum(table [Part] ), counta (table [part]) ), I know this sounds silly but it works!!

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว

      Great !
      /Ruth

  • @dharmatejachary
    @dharmatejachary 5 ปีที่แล้ว

    Link doesn't work for sample pbix

    • @CurbalEN
      @CurbalEN  5 ปีที่แล้ว +1

      All links are here now:
      curbal.com/donwload-center
      /Ruth

  • @alessandromanzieri1509
    @alessandromanzieri1509 4 ปีที่แล้ว

    Thank you! Really useful!

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว +1

      Yey!!
      /Ruth

  • @westgateway8545
    @westgateway8545 2 ปีที่แล้ว

    thanks, my problem solved

    • @CurbalEN
      @CurbalEN  2 ปีที่แล้ว

      Wonderful!

  • @mukeshtaylor
    @mukeshtaylor 2 ปีที่แล้ว

    very useful... Thanks a lot....

  • @RafaelLoureiroSM
    @RafaelLoureiroSM 4 ปีที่แล้ว

    Thank you!!

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      🥳🥳

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      🥳🥳

  • @leopoldocastelangarcia673
    @leopoldocastelangarcia673 4 ปีที่แล้ว

    Fue de muchas ayuda :D

  • @gabrielecianci4985
    @gabrielecianci4985 3 ปีที่แล้ว

    Great!

  • @rachelfrost768
    @rachelfrost768 6 ปีที่แล้ว +1

    Not simple to follow, very discouraging. Can this not be simplified?

    • @CurbalEN
      @CurbalEN  6 ปีที่แล้ว

      Sorry to hear that, there are a lot of resources on DAX, check them out as they might explain it better.
      Don’t give up!
      /Ruth

  • @ЭлектростальскийКолледж-м5й

    Спс!!! ✔

    • @CurbalEN
      @CurbalEN  4 ปีที่แล้ว

      с удовольствием!
      /Ruth

  • @deepakagrawal465
    @deepakagrawal465 8 ปีที่แล้ว +1

    Excellent video, Ruth. Gives us an idea of DAX's powerful flexibility to suit a particular business scenario. The key is to define two measures to take care of filter context. Wondering if Calculate can do some magic with single measure (Food for thought!).
    I had come across similar problem few months back and Peter Albert's answer to a post on stack overflow helped me.
    stackoverflow.com/questions/22613333/dynamic-sum-in-dax-picking-distinct-values

    • @CurbalEN
      @CurbalEN  8 ปีที่แล้ว +1

      +Deepak Agrawal
      Hi Deepak,
      I had the same problem too when I was a beginner and I too got help with a measure that worked but I didn't fully understand it, so that is why I did this video, hopefully it helps others...
      If you try with calculate and you succeed, let us know!
      /Ruth

    • @deepakagrawal465
      @deepakagrawal465 8 ปีที่แล้ว

      Sure. Thanks. (:

    • @deepakagrawal465
      @deepakagrawal465 8 ปีที่แล้ว +1

      Hi Ruth,
      CALCULATE has done it again. You can use the following measure:
      Correct distinct sum =
      SUMX (
      DISTINCT ( Table1[PartDenom] ),
      CALCULATE ( MAX ( Table1[Budget Cost Tooling] ) )
      )
      Meanwhile, Let us all bow to CALCULATE (:

    • @CurbalEN
      @CurbalEN  8 ปีที่แล้ว

      +Deepak Agrawal
      Smart! And thanks for sharing! :)
      /Ruth

    • @CurbalEN
      @CurbalEN  8 ปีที่แล้ว

      +Deepak Agrawal Oh! One more thing, now you need to explain why that works!
      ;)
      /Ruth