Forum Discussion
ssh529
2 years agoRegular Visitor
Dynamically subtracting one option from another within the same variable
Hi everyone, I have data for 8 quarters (but the format of the quarter variable in the data is text, not a date). I'm looking to make a dynamic calculation depending on what quarter I pick in...
marcelsmaglhaes
2 years agoSuper User
Hey ssh529 ,
You can try something like the Comparioson Measure bellow. It's a simple starting point that can be refined to meet your specific requirements. Just make sure to replace 'YourTable' with your actual table name and 'YourValueColumn' with the name of the column containing the values you want to compare.
Comparison Measure =
VAR CurrentQuarter = SELECTEDVALUE('YourTable'[Quarter]) // Replace 'YourTable' with your table name
VAR PreviousQuarter =
IF(
CurrentQuarter = "Q1",
"Q4",
CONCATENATE("Q", TEXT(VALUE(RIGHT(CurrentQuarter, 1)) - 1))
)
RETURN
CALCULATE(
SUM('YourTable'[YourValueColumn]), // Replace 'YourValueColumn' with your value column name
'YourTable'[Quarter] = PreviousQuarter
)