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
MRUry7
Resolver II
Resolver II

Changing results from a table into a measure

Hi, I've created a table using the summarize function below

powerbi dax from this table, how do i add a new measure that shows each value as


DevicesPct = SUMMARIZE('Devices',
          'Devices'[Device],
         "DeviceVisits",Sum(Devices[Visits]),
        "DeviceAvg",Average(Devices[Visits])/100
         )

So the results look like this (After i change it on the table as % of grand total)

MRUry7_1-1708520084499.png

My question is, how do i create a card where i can drop in the details above into separate cards, but formatted in a way such as 
Mobile - 56.19%
Desktop - 42.91%
So i can drop each of these into separate cards?

Any help is appreciated.
Thanks, Steve

 

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

Hi @MRUry7 ,

 

Hope all is going well.

 

Please follow these steps:

 

1. This is the raw data I created and the corresponding calculation sheet based on your description.

vhuijieymsft_0-1708570151646.png

vhuijieymsft_1-1708570151647.png

 

2. I created a calculated column to format "DeviceAvg" as a percentage, with the following syntax:

 

Avg = FORMAT( 'DevicesPct'[DeviceAvg], "Percent") 

 

 

3. Then there is your need to "Mobile - 56.19%   Desktop - 42.91%" format display data, I have two methods:

 

1)Create a measure directly. The DAX syntax is as follows. This method is simpler.

 

merged0 = COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg]))

 

vhuijieymsft_0-1708570287056.png

 

 2)Create a measure for each Device. The measure created by this method can be displayed through cards, but it is more troublesome.

 

merged1 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Mobile")

merged2 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Desktop")

merged3 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Tablet")

merged4 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Unknown")

merged5 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Gaming System")

merged6 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="TV")

 

vhuijieymsft_1-1708570305028.png

 

Please select the method you want according to your needs.

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

2 REPLIES 2
v-huijiey-msft
Community Support
Community Support

Hi @MRUry7 ,

 

Hope all is going well.

 

Please follow these steps:

 

1. This is the raw data I created and the corresponding calculation sheet based on your description.

vhuijieymsft_0-1708570151646.png

vhuijieymsft_1-1708570151647.png

 

2. I created a calculated column to format "DeviceAvg" as a percentage, with the following syntax:

 

Avg = FORMAT( 'DevicesPct'[DeviceAvg], "Percent") 

 

 

3. Then there is your need to "Mobile - 56.19%   Desktop - 42.91%" format display data, I have two methods:

 

1)Create a measure directly. The DAX syntax is as follows. This method is simpler.

 

merged0 = COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg]))

 

vhuijieymsft_0-1708570287056.png

 

 2)Create a measure for each Device. The measure created by this method can be displayed through cards, but it is more troublesome.

 

merged1 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Mobile")

merged2 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Desktop")

merged3 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Tablet")

merged4 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Unknown")

merged5 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="Gaming System")

merged6 = CALCULATE(COMBINEVALUES("-", MAX('DevicesPct'[Device]), MAX('DevicesPct'[Avg])),'DevicesPct'[Device]="TV")

 

vhuijieymsft_1-1708570305028.png

 

Please select the method you want according to your needs.

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Thanks very much. This seems to be what i was looking for.

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.