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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

SPD share Calculation

 i have table name called Master DB .  My table  data looks like the below .

 

Category Dec             Market name            Actuals

 Cigarettes                    AZ                              500

 Cigarettes                    AU                              300

 Cigarettes                   ZM                              200

      RRP                         AZ                              600

      RRP                        AU                              100

      RRP                       ZM                                350

 

 

 

I want calcualte SPD share  for individual  Market name total of the  individual   Category Dec   actuals

 

if suppose  going to calculate spd share for  AZ  for  Cigarettes  category .

 

Cigarettes  totalactuals =1000     

AZ  value for  Category = 500

 

my calculation should be like

 SPD share = ( selected Category Dec   total - selected marketname value) / selected Category Dec   total

 

  Example :  SPD share =(1000-500)/ 1000

 

 

i have created formula below 

 

SPD SHARE =

VAR selectedSPD =
SELECTEDVALUE ( 'Master DB'[Category Dec] )
VAR totalsum =
CALCULATE ( SUM ( 'Master DB'[Actuals] ), ALL ( 'Master DB' ) )
VAR selected_spddesc_value =
CALCULATE ( SUM ( 'Master DB'[Actuals] ), 'Master DB'[Category Dec] = selectedSPD )
RETURN
DIVIDE ( ( selected_spddesc_value - totalsum ), selected_spddesc_value )

 

 

But its taking whole actuals value . i want selected actuals value for the calcualtion.

 

 

thanks in advance .

 

1 ACCEPTED SOLUTION

@Anonymous ,

That will be

New measure =

var _cat = CALCULATE ( SUM ( 'Master DB'[Actuals] ), 'Master DB'[Category Dec] = max( 'Master DB'[Category Dec] ) )

var _self = SUM ( 'Master DB'[Actuals] )

return

divide(_cat -_self,_cat)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@amitchandak  sir i am getting Failed to resolve name 'SELECTEDVALUE'. It is not a valid table, variable, or function name error  

Anonymous
Not applicable

@amitchandak  sir  Not able get that 1000 -500/1000   
For example 1000  -  this is  total value for selected  Cigarettes category desc  .

                     500 - selected market value .

 let me use above  your mentiond measure  sir  

@Anonymous ,

That will be

New measure =

var _cat = CALCULATE ( SUM ( 'Master DB'[Actuals] ), 'Master DB'[Category Dec] = max( 'Master DB'[Category Dec] ) )

var _self = SUM ( 'Master DB'[Actuals] )

return

divide(_cat -_self,_cat)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak  let me try  and will update now sir 

amitchandak
Super User
Super User

@Anonymous , Not able get that 100 -500/100

 

but need be like

 

SPD SHARE =

VAR selectedSPD =
SELECTEDVALUE
VAR totalsum =
CALCULATE ( SUM ( 'Master DB'[Actuals] ), ALL ( 'Master DB' ) )
VAR _select_cat =
CALCULATE ( SUM ( 'Master DB'[Actuals] ), 'Master DB'[Category Dec] = max( 'Master DB'[Category Dec] ) )
VAR _select_mar =
CALCULATE ( SUM ( 'Master DB'[Actuals] ), 'Master DB'[ Market name] = max( 'Master DB'[ Market name] ) )
RETURN
DIVIDE ( ( _select_cat - _select_mar ), totalsum )

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.