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
mdjoshua94
Frequent Visitor

Show % based on 2 tables

Hi all, I have 2 different tables in my power bi which I am interested in making a pie chart from. Is there any ways to merge this large data set tgt? I give example below

Total Order
2
3
4
5

 

OrderSuccess
1Yes
2Yes
3Yes


I would like to show a pie chart of Sucess based on column Total Order (which would obviously be 60%) but my powerbi keeps showing it as 100% based on column order even after addition many-many relationship between Order and Total Order. 

How does this work with thanks!

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

You could consider merging those two tables to make the calculation even easier with the first measure.  If not, the second measure should work with no relationship between the tables.

 

Measure1 = calculate(countrows(MergedTable), MergedTable[Success] = "Yes")/countrows(MergedTable)

 

Measure2 = var denominator = countrows(TotalOrderTable)

var numerator = calculate(countrows(OrderTable), treatas(values(TotalOrderTable[OrderNumberColumn]), OrderTable[OrderNumberColumn]))

return numerator/denominator

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

v-deddai1-msft
Community Support
Community Support

Hi,

 

Would you please try to use the following measure:

Measure =

VAR a =

    COUNTROWS ( 'Table' )

VAR b =

    CALCULATE (

        COUNTROWS ( 'Table' ),

        FILTER (

            ALL ( 'Table' ),

            'Table'[Total Order] IN VALUES ( Table2[Order] )

                && LOOKUPVALUE ( Table2[Success], Table2[Order], 'Table'[Total Order] ) = "Yes"

        )

    )

RETURN

    b / a

Untitled picture1.png

For more details, please refer to https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EW2exHt7NIZCkM_JNa...

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi,

 

Would you please try to use the following measure:

Measure =

VAR a =

    COUNTROWS ( 'Table' )

VAR b =

    CALCULATE (

        COUNTROWS ( 'Table' ),

        FILTER (

            ALL ( 'Table' ),

            'Table'[Total Order] IN VALUES ( Table2[Order] )

                && LOOKUPVALUE ( Table2[Success], Table2[Order], 'Table'[Total Order] ) = "Yes"

        )

    )

RETURN

    b / a

Untitled picture1.png

For more details, please refer to https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EW2exHt7NIZCkM_JNa...

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

mahoneypat
Employee
Employee

You could consider merging those two tables to make the calculation even easier with the first measure.  If not, the second measure should work with no relationship between the tables.

 

Measure1 = calculate(countrows(MergedTable), MergedTable[Success] = "Yes")/countrows(MergedTable)

 

Measure2 = var denominator = countrows(TotalOrderTable)

var numerator = calculate(countrows(OrderTable), treatas(values(TotalOrderTable[OrderNumberColumn]), OrderTable[OrderNumberColumn]))

return numerator/denominator

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.