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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX CALCULATION

I'm trying to GM % on a row based. Net GP/Sales. Please can someone help me. 

Iklizo_0-1651019050476.png

 

12 REPLIES 12
Anonymous
Not applicable

Hi @Anonymous ,

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

 

Best Regards

Community Support Team _ Polly

 

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

Anonymous
Not applicable

Hi @Anonymous ,

Please refer to my pbix file to see if it helps you.

Add an index column first.

Click Home>>Transform data >>Transform data>>Add column>>index column>>From 1.

vpollymsft_0-1651215289446.png

Then create columns.

actual =
VAR _aactual =
    CALCULATE (
        MAX ( 'Table'[actual value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index.1] = EARLIER ( 'Table'[Index.1] ) + 1 )
    )
RETURN
    DIVIDE ( 'Table'[actual value], _aactual )
budget =
VAR _budget =
    CALCULATE (
        MAX ( 'Table'[budget values] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index.1] = EARLIER ( 'Table'[Index.1] ) + 1 )
    )
RETURN
    DIVIDE ( 'Table'[budget values], _budget )

vpollymsft_1-1651215427501.png

 

If I have misunderstood your meaning, please provide more details with your desired output and your pbix file without privacy information.

 

Best Regards

Community Support Team _ Polly

 

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

Anonymous
Not applicable

@amitchandak  I'm looking to calculate Gross Margin on those Gross margin attribute only on  ROW based both on Budget & Actuals. I don't want the GM % to be on Columns. 

Iklizo_0-1651023981723.png

 

@Anonymous , Not I am a bit confused.
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

And share an example of calculation

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 It won't let me share sample file. only Pix

 

 

Iklizo_0-1651027079527.png

 

amitchandak
Super User
Super User

@Anonymous , A measure like

divide(calculate([Measure], filter(Table, search("Net GP",Table[Line Description],,0) >0) ) ,

calculate([Measure], filter(Table, search("Sales",Table[Line Description],,0) >0) ) )

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  541,093.85/2,036,933,92 = Baked Good Gross Margin only 

@Anonymous , And you do not have Baked Good in another column, you want it to also be searched and created a GP?

 

My Idea would be to split this column from behind in power bi

first by (

then by space - Before doing the I will replace sales with net sales so I can split on 2nd space from last

 

If I am on the right path, I need a sample to work on.

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

The Baked goods are attribute on line Description. I need to Divide 
Baked goods Net GP/ Baked goods sales Using the Actuals & Budget meassures. So it will Populate Baked Goods gross margin row based. 

Anonymous
Not applicable

@amitchandak I'm trying to used SelectedValue & Switch function. This is how the actuals & Budget was Calculated. 

Iklizo_0-1651025816288.png

 

@Anonymous , what is the difference in the measure? for each switch value.  I think, need to look into details, what was needed and why the above was needed

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  What was needed is the GM % from Acutal & Budget Values. Divide 541,093.85/2,036,933.92 = Baked Good Gross Margin. Every line descriptioin has a Gross Margin attribute Users wants fill in those gross margin attribute. 

Iklizo_1-1651028135297.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.