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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
dw700d
Post Patron
Post Patron

calculating percent within the same column

I am looking to create a table or matrix with three rows of raw data

StatusFund IV 

 

Fund V                

  Fund VI  Fund Total 
A$1,000,000   $750,000   $0               $1,750,000  
B $450,000$900,000$1,350,000
C$1,100,000$1,300,0001,000,000$3,400,000

 

Then I would like to add two rows that calculate percentage complete.

Row D = (ROW A/ROW C)

Row E = (Sum of (Row A +Row B))/(Row C)

 

Below is what the final product would look like. How can Incorporate the percent calculations in my table/matrix?

 

Status Fund IV  Fund V   Fund VI  Fund Total 
A$1,000,000    $750,000     $0$1,750,000
B $450,000$900,000     $1,350,000  
C$1,100,000$1,300,0001,000,000$3,400,000
D90.91%57.69%0%51.47%
E90.91%92.31%90.00%91.18%

 

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

Hi @dw700d ,

 

1.Create a Status table by entering data. There is no relationship between two tables.

3.png4.png

 

2.Select the Status column and select Unpivot other Columns.

5.png6.png

 

3.Add a Conditional Column to sort the Attribute column.

7.png

 

4.Create a measure.

Measure = 
VAR AA =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Status] = "A" ) )
VAR BB =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Status] = "B" ) )
VAR CC =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Status] = "C" ) )
RETURN
    SWITCH (
        MAX ( 'Status'[Status] ),
        "A", FORMAT ( AA, "$0" ),
        "B", FORMAT ( BB, "$0" ),
        "C", FORMAT ( CC, "$0" ),
        "D", FORMAT ( DIVIDE ( AA, CC ), "0.##%" ),
        "E", FORMAT ( DIVIDE ( AA + BB, CC ), "0.##%" )
    )

 

5.Create the following matrix, this matrix is the result.

8.png

 

 

You can check more details from here.


Best Regards,
Stephen Tao

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

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @dw700d ,

 

1.Create a Status table by entering data. There is no relationship between two tables.

3.png4.png

 

2.Select the Status column and select Unpivot other Columns.

5.png6.png

 

3.Add a Conditional Column to sort the Attribute column.

7.png

 

4.Create a measure.

Measure = 
VAR AA =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Status] = "A" ) )
VAR BB =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Status] = "B" ) )
VAR CC =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [Status] = "C" ) )
RETURN
    SWITCH (
        MAX ( 'Status'[Status] ),
        "A", FORMAT ( AA, "$0" ),
        "B", FORMAT ( BB, "$0" ),
        "C", FORMAT ( CC, "$0" ),
        "D", FORMAT ( DIVIDE ( AA, CC ), "0.##%" ),
        "E", FORMAT ( DIVIDE ( AA + BB, CC ), "0.##%" )
    )

 

5.Create the following matrix, this matrix is the result.

8.png

 

 

You can check more details from here.


Best Regards,
Stephen Tao

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

Greg_Deckler
Super User
Super User

@dw700d - This is likely leading down a rabbit hole of sadness. You could get a measure that based upon "Status" returns one calculation or another but you are likely going to end up pulling all of your hair out trying to swap formats unless you can live with displaying text, then you could use the FORMAT function as part of the output of that measure.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.