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
Anonymous
Not applicable

Display unique items that appeared each year

I am new to DAX and using Power Query & Powerpivot in Excel 2016 to transform and load data to a pivot. I am simply trying to get a list of Unique Characteristics Values (CHAR VAL) and their counts (Sub-Totals) shown for each year. This measure should adjust itself when i add different filters like Country, Char Description etc to Pivot.

 

 

Item Appearance DateItem Appearance Date (Year)CHAR DESCRIPTIONCHAR VALUE
2017-02-072018LSCBBBB
2017-04-192017LSCCCCC
2017-04-192017LCCCCCC
2017-04-192017CCMBBBB
2017-04-192017CLCMBBBB
2017-06-012017LCCCCCC
2017-06-072017LSCAAAA
2017-06-072017CCMDDDD
2017-07-042018CCMGGGG
2017-07-052018CLCMAAAA
2017-07-072018LCCWWWW
2017-07-072018AVMCAAAA
2016-07-172016CLCMEEEE
2016-07-172016LSCFFFF
2016-10-112016CLCMEEEE
2016-10-122016AVMCZZZZ
2017-10-152017LSCAAAA
2017-10-182017LCCHHHH
2017-10-182017CCMBBBB
2018-03-112017CCMBBBB
2018-03-132017LCCYYYY
2018-03-132017CLCMAAAA
2018-04-122018CLCMDDDD
2018-04-132018CCMDDDD
2018-04-172018LCCCCCC
2018-04-172018AVMCCCCC
2018-06-012018LSCRRRR
2018-06-012017LCCWWWW
2018-06-012017CCMXXXX
2018-06-052017CLCMAAAA
2018-06-052017AVMCCCCC
2018-06-122017AVMCBBBB
2018-06-122017LSCHHHH

 

I am trying to answer the following questions:

  1. how many Unique Char Values are present for each Char Description each year?
  2. what are the top 5 or 10 Char Values for each Char Description each year?
  3. If we have 2 years of data, can we compare past year vs previous to determine Emerging or Trending values?
  4. Anything else interesting about this data?

 

Count of CHAR VALCHAR DESC    
Item Appearance Date (Year)CHAR VALAVMCCCMCLCMLCCLSCUniqueCharCounts
2018DDDD 11   
 BBBB    1 
 GGGG 1   1
 WWWW   1  
 RRRR    11
 AAAA1 1   
 CCCC1  1  
2018 Total 222222
2017DDDD 1    
 HHHH   111
 AAAA  2 2 
 WWWW   1  
 YYYY   1 1
 XXXX 1   1
 BBBB131   
 CCCC1  21 
2017 Total 253543
2016FFFF    11
 EEEE  2  1
 ZZZZ1    1
2016 Total 1 2 13

 

 

I have tried following formulae, but not getting the unique list of items and their unique counts in pivot for each year. e.g. like this:

 

DistinctCounts:=DISTINCTCOUNT('Table1'[CHAR VAL]))

UniqueCharCount:=CALCULATE(COUNTROWS(DISTINCT('Table1'[CHAR VAL])),'Table1'[Item Appearance Date (Year)])

 

Can any DAX Experts please help me quickly?

 

1 ACCEPTED SOLUTION

@Anonymous

 

Try this revision

 

Distinct Count With Totals =
IF (
    HASONEFILTER ( tblData[Item Appearance Date (Year) 1] )
        && HASONEFILTER ( tblData[CHAR DESCRIPTION] )
        && HASONEFILTER ( [CHAR VALUE] ),
    [DistinctCount],
    SUMX (
        SUMMARIZE (
            tblData,
            [Item Appearance Date (Year) 1],
            [CHAR DESCRIPTION],
            [CHAR VALUE]
        ),
        [DistinctCount]
    )
)

 


Regards
Zubair

Please try my custom visuals

View solution in original post

16 REPLIES 16

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