Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Wrong count total from calculated measure

I am trying to get a distinct count of the vendor keys for each partner but for some reason every time I bring in the vendorkey column from the fact table it returns 1 for measures, when I remove the vendorkey column it returns the accurate count. Is there something I’m missing?

DAX:

testMeasure = CALCULATE(DISTINCTCOUNT(fact_table[vendor_key]),ALLEXCEPT(dim_partner,dim_partner[partner_name]))

Current Output With Vendor Key:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

Current Output Without Vendor Key:

enter image description here

Expected Output:

Partner             VendorKey testMeasure
Absolutely Pc         4341          1
Affinitas             4341          1
Birak                 4341          1
Blue Shield IT Ltd    4316          3
Blue Shield IT Ltd    4336          3
Blue Shield IT Ltd    4341          3

Note: There is already a one to many relationship between the partner table and fact table

>Solution :

Please test this, and let me know:

testMeasure =
CALCULATE (
    DISTINCTCOUNT ( fact_table[vendor_key] ),
    ALLEXCEPT ( fact_table, dim_partner[partner_name] )
)

Also, DistincCount() is a problematic function, and causes you lots of trouble with your measure if your data grows. change your measure with this. Preference is up to you!

testMeasure =
CALCULATE (
    SUMX ( VALUES ( fact_table[vendor_key] ), 1 ),
    ALLEXCEPT ( fact_table, dim_partner[partner_name] )
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading