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
apai1990
Frequent Visitor

Need help with parameter comparison in Power BI

Hello,

 

I'm a Tableau user and new to Power BI, I got stuck on how to use parameters to create a condition that represents TRUE and FALSE so that I can use them in the filter. I did use the VAR return method but the measure is blank I tried multiple methods but I can't get through or maybe I'm missing something here.

I have parameters "Start year", "End Year", and "Salary period", I want to compare "Start Year" and "End Year" with another table column called "Payment Year" and "Payment periods".

The logic I'm trying to create is as follows:

 

IF [Start Year]=[End Year]

      then [Payment year] = [Start Year] AND [Payment period]= [Salary Period]

ELSEIF 

      [Payment year] = [Start Year] OR [Payment period]>= [Salary Period]

END

 

 Below is the method I applied in Power BI:

 

Time Period = VAR pyS=SELECTEDVALUE('Start Year'[Start Year])
            VAR pyE=SELECTEDVALUE('End Year'[End Year])
            VAR ppS=SELECTEDVALUE('SalaryPeriod'[SalaryPeriod])
            VAR pp=SELECTEDVALUE('Final Table'[Payment Period])
            VAR py=SELECTEDVALUE('Final Table'[Payment Year])
RETURN
IF(pyS=pyE, AND(py=pyS,pp>=ppS),OR(py=pyS,pp>=ppS))

 

Any help will be highly appreciated.

1 ACCEPTED SOLUTION
hackcrr
Super User
Super User

Hi, @apai1990 

I have the following data table:

hackcrr_0-1715470816007.png

hackcrr_1-1715470826636.png

I have the following two parameters:

hackcrr_2-1715470882729.png

hackcrr_3-1715470893190.png

I created a metric using the following DAX expression:

IsInPeriod = 
VAR pyS = SELECTEDVALUE('Start year'[Start year])  
VAR pyE = SELECTEDVALUE('End Year'[End Year])  
VAR ppS = SELECTEDVALUE(SalaryPeriods[SalaryPeriod])  
VAR pp = SELECTEDVALUE(Payments[Payment Period]) 
VAR py = SELECTEDVALUE(Payments[Payment Year])  
  
RETURN  
    IF (  
        NOT ISBLANK(pyS) && NOT ISBLANK(pyE) && NOT ISBLANK(ppS),  
        IF (  
            pyS = pyE,  
            IF (py = pyS && pp = ppS, "In Period", "Not In Period"),  
            IF (py = pyS || py = pyE || (py > pyS && py < pyE) && pp >= ppS, "In Period", "Not In Period")  
        ),  
        "Parameters Not Set"  
    )

Use the following fields in the table vision object:

hackcrr_4-1715470955479.png

The results are as follows:

hackcrr_5-1715470985764.png

hackcrr_6-1715470996027.png

 

 

Best Regards,

hackcrr

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
hackcrr
Super User
Super User

Hi, @apai1990 

I have the following data table:

hackcrr_0-1715470816007.png

hackcrr_1-1715470826636.png

I have the following two parameters:

hackcrr_2-1715470882729.png

hackcrr_3-1715470893190.png

I created a metric using the following DAX expression:

IsInPeriod = 
VAR pyS = SELECTEDVALUE('Start year'[Start year])  
VAR pyE = SELECTEDVALUE('End Year'[End Year])  
VAR ppS = SELECTEDVALUE(SalaryPeriods[SalaryPeriod])  
VAR pp = SELECTEDVALUE(Payments[Payment Period]) 
VAR py = SELECTEDVALUE(Payments[Payment Year])  
  
RETURN  
    IF (  
        NOT ISBLANK(pyS) && NOT ISBLANK(pyE) && NOT ISBLANK(ppS),  
        IF (  
            pyS = pyE,  
            IF (py = pyS && pp = ppS, "In Period", "Not In Period"),  
            IF (py = pyS || py = pyE || (py > pyS && py < pyE) && pp >= ppS, "In Period", "Not In Period")  
        ),  
        "Parameters Not Set"  
    )

Use the following fields in the table vision object:

hackcrr_4-1715470955479.png

The results are as follows:

hackcrr_5-1715470985764.png

hackcrr_6-1715470996027.png

 

 

Best Regards,

hackcrr

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

 

nandic
Super User
Super User

@apai1990 i am struggling to understand the output of the logic.
Dax output is single value, 1 condition.

Example:
If you start like this:

IF(Periods[Start Year]=Periods[End Year],
now you should write expected output, example: Periods[Start Year] and name of this new column will be "Payment Year".

In your statement above, instead of 1 output you wrote:

then [Payment year] = [Start Year] AND [Payment period]= [Salary Period]

ELSEIF 

As these are 2 outputs, the logic is not understandable to dax.

The easiest would be to share screenshot of data and expected output, then it will be clear what to do.

Cheers,
Nemanja Andic

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.