Unique count

  • Unique count

    Posted by DSC Communities on February 22, 2023 at 5:36 pm
    • Ab Ab

      Member

      February 22, 2023 at 5:36 PM

      Hello,Ā 

      I have data table and data table contains item and country code. The item has duplicate entry and country code has unique entry against the item.

      The same item has more than one country code or sometimes any one of them. (DMK or ADMK)Ā 

      Condition:

      If same item has more than one country code then first priority is DMK and second priority is ADMK. If there is no duplicate entry then return the available country code according to the item.Ā 

      Result :

      Now, I want to get the unique country code based on the above mentioned condition.Ā 

      I already created calculate column to get the desired result but I am looking for measure instead of calculated columns.Ā 

      I am using the below mentioned formulas to get the desired result but I want the same result by using measure instead of calculated columns. (Both of them giving same result but I am trying to apply the same login measure but it’s not working)

      Result =
      IF(
      Ā  Ā  ISEMPTY(
      Ā  Ā  Ā  Ā  FILTER(
      Ā  Ā  Ā  Ā  Data,Data[Item]=EARLIER(Data[Item])
      Ā  Ā  Ā  Ā  && Data[Country Code] = “DMK”)
      Ā  Ā  Ā  Ā  ),
      Ā  Ā  Ā  Ā  Data[Country Code],“DMK”)

      Result1 =
      VAR DMK =
      CALCULATE(
      Ā  Ā  COUNTROWS(Data),
      Ā  Ā  FILTER(Data,
      Ā  Ā  Data[Item]=EARLIER(Data[Item])
      Ā  Ā  && Data[Country Code] = “DMK”)
      )
      RETURN
      IF(DMK>0,“DMK”,[Country Code])

      Also, I am attaching here the Power BI file for your reference. Could you please help me.

      https://www.dropbox.com/s/y1q6e4w0sndhnd7/Unique%20count%20based%20on%20the%20text%20-%2023-02-2023.pbix?dl=0

      ——————————
      Ab Ab
      Engineering
      ——————————

    • Vilmar Santos

      Member

      February 24, 2023 at 6:23 PM

      Veja se ajuda

      zResult = 
      VAR Var1 =
          SELECTEDVALUE ( Data[Item] )
      RETURN
          IF (
              ISEMPTY ( FILTER ( ALL ( Data ), [Item] = Var1 && [Country Code] = "DMK" ) ),
              SELECTEDVALUE ( Data[Country Code] ),
              "DMK"
          )
      zResult1 = 
      VAR Var1 =
          SELECTEDVALUE ( Data[Item] )
      VAR DMK =
          CALCULATE (
              COUNTROWS ( Data ),
              FILTER ( ALL ( Data ), [Item] = Var1 && [Country Code] = "DMK" )
          )
      RETURN
          IF ( DMK > 0, "DMK", SELECTEDVALUE ( Data[Country Code] ) )

      ——————————
      Vilmar Santos
      ——————————
      ——————————————-

    DSC Communities replied 2 years, 7 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Unique count’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!