cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sheap069
Helper III
Helper III

Measures in Table Visual

Hi,

I have two data sets as shown here (sample data and expected result)

 

data 1

Application IDAttribute 1Attribute 2Attribute 3Attribute 4
1TRUEFALSEFALSETRUE
2FALSEFALSEFALSETRUE
3TRUEFALSEFALSETRUE
4FALSETRUEFALSETRUE
5FALSEFALSEFALSETRUE
6FALSETRUEFALSETRUE

 

data 2

Application IDAttribute 1Attribute 2Attribute 3Attribute 4
7FALSEFALSETRUEFALSE
8TRUEFALSETRUEFALSE
9TRUETRUETRUEFALSE
10FALSEFALSETRUEFALSE
11FALSEFALSETRUEFALSE
12TRUETRUETRUEFALSE

 

I have many measures to calculate counts and rates of the attributes. Those are calculated based on if the Attributes are true or false. These are the results 

data 1

 Attribute 1Attribute 2Attribute 3Attribute 4
Count2206
Rate33%33%0%100%

data 2

 Attribute 1Attribute 2Attribute 3Attribute 4
Count3260
Rate50%33%100%0%

 

I want to have these measures in a Table Visual like this: 

 Data 1Data 2
 # of AppsRate# of Apps Rate
Attribute 1233%350%
Attribute 2233%233%
Attribute 300%6100%
Attribute 46100%00%

 

I'm not sure how to construct this table based on all the measures I've created in my data. 

 

Thank you

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

Hi,  @sheap069 

Try follow steps :
1.Add a custom column to mark table name in each table

11.png

 

2. Upivote attribute columns  as below:
12.png

3.Append queries as new query and then close & Apply

13append queries as new.png

You will get a new table as below:
(make sure the field "Value" is text type)

14.png

 

4.Create measure as below:

Count_value = 
CALCULATE (
    COUNT  ( Append1[Value] ),
    FILTER (
        ALLEXCEPT ( Append1, Append1[Table Name], Append1[Attribute] ),
        Append1[Value] <> BLANK ()
    )
) + 0
Count_value_true = 
CALCULATE (
    COUNT( Append1[Value] ),
    FILTER (
        ALLEXCEPT ( Append1, Append1[Table Name], Append1[Attribute] ),
        Append1[Value] = "True"
    )
) + 0
Rate = [Count_value_true]/[Count_value]

 

The  result will show as below:

15.png

Please check my sample file for more details.

 

 

Best Regards,
Community Support Team _ Eason
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

5 REPLIES 5
v-easonf-msft
Community Support
Community Support

Hi,  @sheap069 

Try follow steps :
1.Add a custom column to mark table name in each table

11.png

 

2. Upivote attribute columns  as below:
12.png

3.Append queries as new query and then close & Apply

13append queries as new.png

You will get a new table as below:
(make sure the field "Value" is text type)

14.png

 

4.Create measure as below:

Count_value = 
CALCULATE (
    COUNT  ( Append1[Value] ),
    FILTER (
        ALLEXCEPT ( Append1, Append1[Table Name], Append1[Attribute] ),
        Append1[Value] <> BLANK ()
    )
) + 0
Count_value_true = 
CALCULATE (
    COUNT( Append1[Value] ),
    FILTER (
        ALLEXCEPT ( Append1, Append1[Table Name], Append1[Attribute] ),
        Append1[Value] = "True"
    )
) + 0
Rate = [Count_value_true]/[Count_value]

 

The  result will show as below:

15.png

Please check my sample file for more details.

 

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you very much, this has the desired result!

Fowmy
Super User
Super User

@sheap069 

The best approach to get the desired results is to UnPivot the Attribute columns do the calculation using DAX.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi,

Could you provide an example please? How would I do the calculations? Do I do it in the Power Query Editor in the table?
Thank you 

@sheap069 

 

You can do the transformations in PQ and the calculations using DAX after loading the data from PQ.

 

To unpivot data, refer to this video: 

 

https://youtu.be/Vff2kRBM95o

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Power BI Show Episode 10 Recap

The Power BI Community Show

Watch the playback when Amit Chandak, a Power BI Super User, demos how to use Field Parameters to make reports more dynamic.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.

Ignite 2022

What's Next at Microsoft Ignite 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Top Solution Authors