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

Help with formula percentage with filter between multiple tables

Hi!

I need help creating a DAX formula. The result I want to get from the formula is:
the percentage of purchase orders per supplier and employee compared to the total purchase orders per employee.

I'm fairly new to DAX formulas, so I could use some help.

I have the following data:
- Table person drafter (= employee name)
- Formula number of suppliers (the value is always 1 when these are expanded in the matrix)
- Formula number of total purchase orders

I have made the following formula:
Unique number of purchase orders % =
CALCULATE
(DISTINCTCOUNT(d_orderorder[Order order code]),
FILTER(d_person_drafter, d_person_drafter[Employee]))

 

This formula is not shown in the table when I drag it in there

Visualization with column names =
Employee names - Number of suppliers where ordered - Number of purchase orders (per supplier and employee will be shown here)

After expanding the matrix, all the names of the suppliers per employee are shown where the order has been placed, so the value becomes 1 per supplier name, and the number of purchase orders per supplier. Next to this I want to have the column what the percentage is then.

Employee A has created a total of 3900 purchase orders at 107 suppliers. Of those 3900 orders, 600 were ordered from supplier X. That's 15%. That is the result I want to get from the formula.

Thank you very much for all the help!

5 REPLIES 5
Anonymous
Not applicable

Hi,

 

Unfortunately, this is not yet the solution. Below is an example of my matrix. I keep getting 100% on the expanded matrix.
I can't put the suppliers in the columns because we are talking about multiple suppliers per person.

 

Unfortunately, this is not yet the solution. Below is an example of my matrix. I keep getting 100% on the expanded matrix.
I can't put the suppliers in the columns because we are talking about hundreds of suppliers per person.

Nicolett_0-1624452630579.png

 

Matrix rows: d_person_drafter[Employee] + d_orderorder[Supplier] + Measure total of order code

No matrix columns

Matrix values: measurement number of suppliers + Measure total of order code + [Percentage] (measure from you @DataInsights )

 

Nicolett_1-1624452809005.png

 

This matrix:

Nicolett_3-1624453242193.png

 

 

the results above should look like this

Nicolett_4-1624453278801.png

 

 

Thanks!

@Anonymous,

 

I added the measures [Count Supplier] and [Count Order Code] as shown below. You have one additional field in Rows.

 

DataInsights_0-1624484314770.png

 

DataInsights_1-1624484324085.png

 

Is this the correct result? If not, would you provide a link to your pbix so I can analyze further? You can use sample data to illustrate the issue.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi!

 

It is the correct outcome. I don't think it works for me because I can't make a direct relationship between the different tables. I've tried to put this in the fact table (f_orderorderrule) using calculated columns, but then I still get 100% everywhere.

Nicolett_0-1624620056656.png

 

Is there a detour for this? As you can see above, the relationships are quite complex and I can't make any further changes to them. 

When I want to create a relationship between the purchase order and person drafter, I get the message that this is an ambiguous relationship and therefore cannot be executed.

@Anonymous,

 

I recommended reviewing and improving the data model (star schema is best). It will make calculations easier. Bidirectional cross filtering should be used only when absolutely necessary (one-to-one relationships are the exception, since it's the only option). If you need bidirectional cross filtering, you can use the CROSSFILTER function inside CALCULATE.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




DataInsights
Super User
Super User

@Anonymous,

 

Try this solution.

 

1. Data model:

 

DataInsights_0-1624121900941.png

 

2. Measure:

 

Percentage = 
VAR vNumerator =
    COUNT ( d_orderorder[Order Code] )
VAR vDenominator =
    CALCULATE (
        COUNT ( d_orderorder[Order Code] ),
        ALLEXCEPT ( d_orderorder, d_person_drafter[Employee] )
    )
VAR vResult =
    DIVIDE ( vNumerator, vDenominator )
RETURN
    vResult

 

3. Matrix:

 

DataInsights_2-1624122058194.png

Matrix rows: d_person_drafter[Employee]

Matrix columns: d_orderorder[Supplier]

Matrix values: [Percentage] (measure above)

 

 

Table d_orderorder:

 

DataInsights_3-1624122103930.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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