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

Calculating a count with certain conditions

I have the following tables:

 

P/T :

 

ID  CC.No   From Region   To Region   From PS   To  PS

1        123              A                   A                      X          H

2         345            B                   D                      Y          I

3         234            C                   E                       Z         Z

.

.

 

And another Table called ZH:

 

CC.No       Region       PSL

123              A               X

233              B               Y

455              C               Z

 

I want to create a measure that calculates the Count of ID with conditions :

 

If a Region is selected from the ZH table in the filters and From Region is not equal to To Region, then the measure value appears otherwise 0, and in the same code for the PSL as well.

 

A user can select only a PSL or Region at one time (Which I can put as a note). The 2 tables are connected by CC.No.

 

Any suggestions?

 

Thank You!

4 REPLIES 4
Phil_Seamark
Employee
Employee

HI @Anonymous

 

What is the direction of the relationship between the two tables?  Oh, and can you please post an expected result based on the sample dataset you have provided.

 

Cheers,

 

Phil


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@Phil_Seamark 

 

Hey, it is in Single Direction.

 

The tables are:

Plan 1.PNG

Plan 2.PNG

 

The To CC No in the Prom/Trans is liked to the CC No in the ZH Table. (Many to One - Single Direction) 

 

I want to create a measure such that if the PSL or Region is a report  level filter:

 

1) Only a PSL or a Region can be selected one by one (When PSL is selected then user should not select a region- tjis part can be mentioned as a note to the end user)

2) The measure gives a  value only when a region or psl is selected

3)Whatever region or PSL is selected by the user, the measure should not include that value in From PSL or From Reg. For exacple if PSL U is selected, then this would link to TO PSL in Prom/Trans Table because of the link. so it should filter such that From PSL is NOT EQUAL to U, and calculate for the remaining.

 

Hope I was able to explain it clearly! Thanks! 

hi, @Anonymous

the sample dataset you have provided is a little confusing. could you please share some sample data that is well convenient to create the relationship and calculate, as well as the expected output.

 

Do mask sensitive data before uploading.

 

  

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-lili6-msft

 

Hey, The Qlik View equivalent formula is as follows:

 

=if(getselectedcount(PSL_TEXT)>0,

count(DISTINCT(if( PRTR.FrPSL<>PRTR.ToPSL, PRTR.ID))),
 if(getselectedcount(REGION)>0,

count(DISTINCT(if( PRTR.FrRegion<>PRTR.ToRegion, PRTR.ID))),
 
 )

 

A user can choose a PSL or a Region only one at a time. When they select a PSL, this gets connected to TOPSL in the PROM TRANS Table (As the TO CC No. and CC No. are connected). It should return back the count where FR.PSL is not equal to ToPSL ( That is if ToPSL is A then FrPSL should be all others except A)

 

I hope this was clearer. Thanks!

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.