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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
hashtag_pete
Helper V
Helper V

Divide two Calculation Items

Hello community, 

 

I have a calculation group where I have a couple of calculation items, which perform a SUMX of a measure SUM(kg) and a referenced table with several columns, where I have the prices at a certain implementation date, e.g.

Jan21:
SUMX (
    'BX_Table',
    SELECTEDMEASURE()
        * RELATED ( 'VRP Prices'[01.01.2021] )
)


Jun21:
SUMX (
    'BX_Table',
    SELECTEDMEASURE()
        * RELATED ( 'VRP Prices'[01.06.2021] )
)

via a slicer on the calculation group, the user can chose the price applied to the SELECTEDMEASURE(kg) he wants to see. That works fine. 

What I want to achieve now, is a DIVIDE or subtraction when two Calculation Items are chosen. I wouldn't mind if the formular breaks when more then two Calculation Items are chosen - in the first instance, I just want to show the % between the value June vs January.

My first attempt was at reading out the Calculation items used, but this does not seem to work. Has anyone an idea?

 

Thanks a lot!

1 ACCEPTED SOLUTION

I think I got the syntax for TREATAS wrong, try using VALUES( CalcGroupSlicer1[Name])

View solution in original post

3 REPLIES 3
hashtag_pete
Helper V
Helper V

Hello @johnt75 
thanks for your suggestion, however it won't work for me. I tried several things, but maybe I am misinterpreting your formular:

In the comparison measure, the TREATAS function always gives me an error. Is the Expression missing?

I have as a first snippet:

Comparison Measure = 
    VAR firstValue = 
        CALCULATE(
            [Summe Gewicht kg],  //this is my base measure, also used for Calculation Group
            TREATAS(CalcGroupSlicer1[Name], ImplementaionDateSelection[Name]))  //first element is underlined red, and following the syntax an expression is needed here. However, I cannot insert SELECTEDVALUE(CalcGroupSlicer1[Name]) so I don't know what expression is needed. 
        

 looking at your formular, it looks like you have two columns in your TREATAS, but this throws an error?

I think I got the syntax for TREATAS wrong, try using VALUES( CalcGroupSlicer1[Name])

johnt75
Super User
Super User

You could create 2 new copies of your calculation group table just for use on the slicers.

Calc slicer 1 = VALUES('Calculation Group')
Calc slicer 2 = VALUES('Calculation Group')

Do not create any relationships from these tables, leave them totally disconnected.

You can then create measure to perform your division or subtraction or whatever like

Comparison measure =
var firstValue = CALCULATE( [Base measure], TREATAS( 'Calc slicer 1'[Calc item], 'Calculation Group'[Calc item]) )
var secondValue = CALCULATE( [Base measure], TREATAS( 'Calc slicer 2'[Calc item], 'Calculation Group'[Calc item]) )
return DIVIDE( firstValue, secondValue )

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.