Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
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:
Any help will be highly appreciated.
Solved! Go to Solution.
Hi, @apai1990
I have the following data table:
I have the following two parameters:
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:
The results are as follows:
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @apai1990
I have the following data table:
I have the following two parameters:
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:
The results are as follows:
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@apai1990 i am struggling to understand the output of the logic.
Dax output is single value, 1 condition.
Example:
If you start like this:
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
User | Count |
---|---|
87 | |
84 | |
70 | |
62 | |
56 |
User | Count |
---|---|
137 | |
110 | |
92 | |
84 | |
69 |