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

Need help with creating a measure

Hi All,

 

I have data in the following format. 

LOCReport NameChannelKPIPeriodProductData
SpainReport 1CH 1CH 1 - Brand DetailsJan-17Product120788
SpainReport 1CH 1CH 1 - % Media Used in DetailsJan-17Product153
UKReport 1CH 1CH 1 - Brand DetailsJan-17Product1746
FranceReport 1CH 1CH 1 - Brand DetailsJan-17Product1309
ItalyReport 1CH 1CH 1 - Brand DetailsJan-17Product12983
ItalyReport 1CH 1CH 1 - % Media Used in DetailsJan-17Product14
BrazilReport 1CH 1CH 1 - Brand DetailsJan-17Product18820
BrazilReport 1CH 1CH 1 - % Media Used in DetailsJan-17Product1798
MexicoReport 1CH 1CH 1 - Brand DetailsJan-17Product18283
MexicoReport 1CH 1CH 1 - % Media Used in DetailsJan-17Product12847
TurkeyReport 1CH 1CH 1 - Brand DetailsJan-17Product14563
TurkeyReport 1CH 1CH 1 - % Media Used in DetailsJan-17Product12360
ItalyReport 1CH 1CH 2 - Brand DetailsJan-17Product11
BrazilReport 1CH 1CH 2 - Brand DetailsJan-17Product11
UKReport 1CH 1CH 3 - Brand DetailsJan-17Product168
TurkeyReport 1CH 1CH 3 - Brand DetailsJan-17Product12

 

I need the output as follows;

 

CH 1 - Brand Details46492
CH 1 - % Media Used in Details13.04%

 

 

where 'CH 1 - Brand Details' is a simple sum

but for 'CH 1 - % Media Used in Details' it should be the sum of 'CH 1 - % Media Used in Details' divided by sum of 'CH 1 - Brand Details'

 

I hope this make sense. Any help would be appreciated.

 

Kris

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous

 

Add this Measure in your Table

 

Measure=
IF (
    HASONEVALUE ( Table1[KPI] ),
    IF (
        VALUES ( Table1[KPI] ) = "CH 1 - Brand Details",
        SUM ( Table1[Data] ),
        IF (
            VALUES ( Table1[KPI] ) = "CH 1 - % Media Used in Details",
            ROUND (
                (
                    SUM ( Table1[Data] )
                        / CALCULATE ( SUM ( Table1[Data] ), Table1[KPI] = "CH 1 - Brand Details" )
                        * 100
                ),
                2
            )
        )
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous

 

Add this Measure in your Table

 

Measure=
IF (
    HASONEVALUE ( Table1[KPI] ),
    IF (
        VALUES ( Table1[KPI] ) = "CH 1 - Brand Details",
        SUM ( Table1[Data] ),
        IF (
            VALUES ( Table1[KPI] ) = "CH 1 - % Media Used in Details",
            ROUND (
                (
                    SUM ( Table1[Data] )
                        / CALCULATE ( SUM ( Table1[Data] ), Table1[KPI] = "CH 1 - Brand Details" )
                        * 100
                ),
                2
            )
        )
    )
)

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Hi Zubair,

 

Thanks for the reply, it works well. How can I make it dynamic, for example, if I have more than 1 item to do these kind of calculations ? Is it possible by using a mapping table where I can put the items and do the calculations?

 

Kris

Hi @Anonymous

Yes you can make them dynamic. Just Create a separate table with items you want.

Insert them as slicer.

 

Then you can replace the hardcoded "CH 1 - Brand Details" and "CH 1 - % Media Used in Details"

with VALUES (SlicerTable[Column])

 

 

 


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Sorry for the late reply.

 

Thanks for the help. I'll try it.

 

Kris

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.