Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
datapal04
Frequent Visitor

Counting for 2 Columns

Hello,

I need to create a measure that will count for 2 columns even though one of the columns is being used as a key for the relationship (many-to-many). Let me explain through an example. 

I have the dimension table below:

Primary Complaint CodeSecondary Complaint CodeMetric
General Announcements  (Safety, Etiquette, & non-Status)Customer BehaviourEnforcement of Quiet Zone on upper level of train coaches
Service Change Communication – ContentService Change Communication – Timeliness/FrequencyKeeping me informed of upcoming schedule changes
General Announcements  (Safety, Etiquette, & non-Status)Service Status Communication – Timeliness/FrequencyFrequency of announcements on board the train 

The Primary Complaint Code column is being used as a key to relate to the fact table (Complaint Code) below:

Case_NumberComplaint Code
301-553535-N9D9V7Service Status Communication – Timeliness/Frequency
301-553613-H6Y2R5Customer Behaviour
301-553632-V7R4D1Customer Behaviour
301-553700-B6R1S4Service Change Communication – Content
301-553724-G1R7G6Service Change Communication – Timeliness/Frequency
301-553737-H8C8G9General Announcements  (Safety, Etiquette, & non-Status)
301-553860-R3C0Y2Customer Behaviour
301-553967-R9C2N1Service Change Communication – Content
301-553999-Y7R8G2Service Change Communication – Content
301-554008-X3C1N4Customer Behaviour
301-554020-J4G4D2Customer Behaviour
301-554101-F2Y1T3General Announcements  (Safety, Etiquette, & non-Status)
301-554214-V2H5W1Service Status Communication – Timeliness/Frequency
301-554399-J4V0V3General Announcements  (Safety, Etiquette, & non-Status)

The measure I need to create will need to take the distinct count of the Case_Number for the sum of Primary and Secondary complaint codes for every Metric. The expected result is below:

MetricCount
Enforcement of Quiet Zone on upper level of train coaches8
Keeping me informed of upcoming schedule changes4
Frequency of announcements on board the train 5

Thanks in advance for your help!

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @datapal04 ,

 

My steps are as follows:

1. In the Power Query Editor, select these two columns and unpivot them.

vcgaomsft_0-1659692214764.png

2. Close and apply.

vcgaomsft_2-1659692374194.png

3. New relationship.

vcgaomsft_1-1659692351150.png

4. New measure:

COUNT = COUNT(FactTable[Complaint Code])

5. Result:

vcgaomsft_3-1659692580828.png

6. The PBIX file is attached for reference.

 

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

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @datapal04 ,

 

My steps are as follows:

1. In the Power Query Editor, select these two columns and unpivot them.

vcgaomsft_0-1659692214764.png

2. Close and apply.

vcgaomsft_2-1659692374194.png

3. New relationship.

vcgaomsft_1-1659692351150.png

4. New measure:

COUNT = COUNT(FactTable[Complaint Code])

5. Result:

vcgaomsft_3-1659692580828.png

6. The PBIX file is attached for reference.

 

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.