Forum Discussion

cottrera's avatar
cottrera
Post Prodigy
4 years ago
Solved

Distinct Count Buckets

Hi 

 

I have a facts table that has the following columns - Property Ref, Score and Measure. Each property ref has exactly 8 measures each with scores. 

 

Property RefSCOREMeasure
180Arrears
180Damp & Mould
180Damp related health issues
180Guttering
180Pest Control
180Plumbing
1850Job Volume
18100Vulnerable
1851330Guttering
1851330Pest Control
18513325Plumbing
18513375Damp & Mould
18513350Arrears
18513325Damp related health issues
18513325Job Volume
1851330Vulnerable
2843150Damp & Mould
2843150Damp related health issues
2843150Guttering
2843150Pest Control
2843150Plumbing
284315100Arrears
284315100Job Volume
284315100Vulnerable
20850Arrears
208100Damp & Mould
208100Damp related health issues
208100Pest Control
208100Plumbing
208100Guttering
208100Job Volume
208100Vulnerable

 

I also have a buckets table with no relationship to the facts table

OrderFromToCategory 
1400650CAT 4
2300385CAT 3
3200285CAT 2
40185CAT 1

 

I would Like to create a DAX function SUMS the total score per property ref and then counts the distinct property ref that have a total score that matches between the From and To value of my bucket table.

 

For example, i would exspect the see a result similar to this..

Category Distinct Property Count 
CAT 16,403
CAT 22,984
CAT 31,363
CAT 4121

 

 

thank you Richard

  • Hi, 

     

    I think this should work for you

    Distinct Property Count =
    var _scores = SUMMARIZE(Fact_Table,Fact_Table[Property Ref], "Score", SUM(Fact_Table[SCORE]))
    var _count = SUMX(_scores, IF([Score] <= SELECTEDVALUE(Buckets_Table[To]) && [Score] >= SELECTEDVALUE(Buckets_Table[From]),1))
    return _count  

     

     

2 Replies

  • AntonioM's avatar
    AntonioM
    Solution Sage

    Hi, 

     

    I think this should work for you

    Distinct Property Count =
    var _scores = SUMMARIZE(Fact_Table,Fact_Table[Property Ref], "Score", SUM(Fact_Table[SCORE]))
    var _count = SUMX(_scores, IF([Score] <= SELECTEDVALUE(Buckets_Table[To]) && [Score] >= SELECTEDVALUE(Buckets_Table[From]),1))
    return _count  

     

     

  • Thank you AntonioM for your quick response the measure worked fine 😁