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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need to Parameterize 2 columns in the DAX measure calculations and slicer to select the param values

I am trying to create a measure using DAX,

scenario:
COMPARE_REVENUE = VAR SRC_REVENUE = CALCULATE(SUM([SRC_AMOUNT]),
                                                                        NOT(CONTAINSSTRING([REVENUE_TYPE],"CRA")),
                                                                       [FISCAL_QUARTER]="Q2FY23",
                                                                       [WEEK]="Wk5.4")
VAR TGT_REVENUE = CALCULATE(SUM([TGT_AMOUNT]),
                                  [FISCAL_QUARTER]="Q2FY23",
                                  [WEEK]="Wk5.4")
return
IF(SRC_REVENUE = TGT_REVENUE,"#00FF00","#FF0000")

---- This calculation is applied to a shape background color conditional formatting, so that if the values are matching it will display green color, otherwise it will show red.
But I need to parameterize the Fiscal Quarter and Week values and required as a slicer to get a dynamic report.
Fiscal Quarter = Q3FY22, Q4FY22, Q1FY23, Q2FY23.... Week = Wk1.1 to Wk12.4
Please give some inputs to get the appropriate result for this idea. Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

You can refer to the following suggestion.

1.You can create two new table,e,g

Fiscal Quarter=SUMMARIZE('Table',[FISCAL_QUARTER])
Week=SUMMARIZE('Table',[WEEK])

Then put the columns of these two tables to slicers.

2.Then modify the measure

COMPARE_REVENUE =
VAR SRC_REVENUE =
    CALCULATE (
        SUM ( [SRC_AMOUNT] ),
        NOT ( CONTAINSSTRING ( [REVENUE_TYPE], "CRA" ) ),
        'Table'[FISCAL_QUARTER] IN VALUES ( 'Fiscal Quarter'[FISCAL_QUARTER] ),
        'Table'[WEEK] IN VALUES ( 'Week'[WEEK] )
    )
VAR TGT_REVENUE =
    CALCULATE (
        SUM ( [TGT_AMOUNT] ),
        'Table'[FISCAL_QUARTER] IN VALUES ( 'Fiscal Quarter'[FISCAL_QUARTER] ),
        'Table'[WEEK] IN VALUES ( 'Week'[WEEK] )
    )
RETURN
    IF ( SRC_REVENUE = TGT_REVENUE, "#00FF00", "#FF0000" )

 

Best Regards!

Yolo Zhu

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

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you, Yolo Zhu! I will try this method to fix this issue.

Anonymous
Not applicable

Hi @Anonymous 

You can refer to the following suggestion.

1.You can create two new table,e,g

Fiscal Quarter=SUMMARIZE('Table',[FISCAL_QUARTER])
Week=SUMMARIZE('Table',[WEEK])

Then put the columns of these two tables to slicers.

2.Then modify the measure

COMPARE_REVENUE =
VAR SRC_REVENUE =
    CALCULATE (
        SUM ( [SRC_AMOUNT] ),
        NOT ( CONTAINSSTRING ( [REVENUE_TYPE], "CRA" ) ),
        'Table'[FISCAL_QUARTER] IN VALUES ( 'Fiscal Quarter'[FISCAL_QUARTER] ),
        'Table'[WEEK] IN VALUES ( 'Week'[WEEK] )
    )
VAR TGT_REVENUE =
    CALCULATE (
        SUM ( [TGT_AMOUNT] ),
        'Table'[FISCAL_QUARTER] IN VALUES ( 'Fiscal Quarter'[FISCAL_QUARTER] ),
        'Table'[WEEK] IN VALUES ( 'Week'[WEEK] )
    )
RETURN
    IF ( SRC_REVENUE = TGT_REVENUE, "#00FF00", "#FF0000" )

 

Best Regards!

Yolo Zhu

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

 

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.