Forum Discussion

gadlakha's avatar
gadlakha
Frequent Visitor
3 years ago

DAX Query

Hi All,

I have a table that lists the Release_IDs, Release_Versions, Release_Category, Release_BaseVersion and a flag to specify if a given release was external or not.

IDVersionCategoryBaseisRelease
616XYZ.1.7.1master1.7False
616XYZ.1.7.1master1.7False
648XYZ.1.7.5master1.7False
654XYZ.1.7.6master1.7True
655XYZ.1.7.7master1.7False
763XYZ.1.7.34master1.7False
1423XYZ.1.9.0.2master1.9.0False
1427XYZ.1.9.0.3master1.9.0True
1460XYZ.1.9.0.12master1.9.0False
1463XYZ.1.9.0.13master1.9.0False
876XYZ.1.7.59master1.7False
1003XYZ.1.8.0.9master1.8.0False
1004XYZ.1.7.0.5r1.7.01.7.0False
1005XYZ.1.7.0.5r1.7.01.7.0True
1007XYZ.1.7.82master1.7.0False
1169XYZ.1.8.0.32master1.8.0False
1466XYZ.1.9.0.12master1.9.0True
1468XYZ.1.9.0.14master1.9.0False
1593XYZ.1.9.0.45master1.9.0False
1598XYZ.1.9.0.46master1.9.0True
1603XYZ.1.9.0.47master1.9.0False
1171XYZ.1.7.0.32r1.7.01.7.0False
1162XYZ.1.8.0.29master1.8.0True

 

What I want is to add a new column that would state the last release build version based on Release_Category and Release_BaseVersion. A given Release_Category and Release_BaseVersion could have multiple external releases and thus all subsequent Release_ID should point to the last available release build version for a given category.

Any help would be greatly appreciated.

 

Regards.

6 Replies

    • gadlakha's avatar
      gadlakha
      Frequent Visitor

      Hey, Thanks for your reply.

      I did tried the solution but the result is not as expected. Below is what I get as a new column with your proposed solution:

      I am confused what a 1 or 0 denotes here.

      The expected outcome would be as below:

      Appreciate if you could help.

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    gadlakha Try:

    Category = 
      VAR __Category = [Category]
      VAR __Base = [Base]
      VAR __Max = MAXX(FILTER(ALL('Table'),[Category] = __Category && [Base] = __Base),[ID])
      VAR __Result = MAXX(FILTER(ALL('Table'),[ID] = __ID),[Version])
    RETURN
      __Result
    • gadlakha's avatar
      gadlakha
      Frequent Visitor

      Hi, Thanks for the reply. I did tried it out but the data is not as expected. Below is what I get when I add a new column based on your reply:

      As you could see, this is not right. For the very first row, the last available release for category: master and base: 1.7 is with ID: 654. Thus, any row with category: master, base: 1.7 and ID less than 654 should not have an entry.

      The right expected data set would be as below:

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi gadlakha ,

       

      Plese try this:

      LastRelId = 
      CALCULATE (
          MAX ( 'Table'[ID] ),
          FILTER (
              ALL ( 'Table' ),
              'Table'[isRelease] = TRUE ()
                  && 'Table'[Category] = EARLIER ( 'Table'[Category] )
                  && 'Table'[Base] = EARLIER ( 'Table'[Base] )
                  && 'Table'[Index] <= EARLIER ( 'Table'[Index] )
          )
      )

      Best Regards,
      Gao

      Community Support Team

       

      If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

      How to get your questions answered quickly --  How to provide sample data in the Power BI Forum