Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi every one,
I'm struck and really struggling to build a logic in power BI, I'm looking for a solution to reslove in DAX.
i have this in my power query editor...and i dont work very well...some records dont match
this is the result im looking for.
and this is what i get (some of the criteria are misclassified)
Power Query Code
criteria 90%
last year - CP5
Last 2 yeasr - CP 4
last 5 years - CP 2
if [#"Fecha "] > #date(2022,1,1) and [Cumple]>90 then "CP5"
else if [#"Fecha "] > #date(2020,12,30) and [Cumple]>90 then "CP4"
else if [#"Fecha "] > #date(2017,1,1) and [Cumple]>90 then "CP2"
Criteria 60%
last year - CP4
Last 2 yeasr - CP 3
last 5 years - CP 1
else if [#"Fecha "] > #date(2022,1,1) and [Cumple]>60 then "CP4"
else if [#"Fecha "] > #date(2020,1,1) and [Cumple]>60 then "CP3"
else if [#"Fecha "] > #date(2017,1,1) and [Cumple]>60 then "CP1"
else "Null"
any help or advice is appreciated
Solved! Go to Solution.
Hi @A7Russ ,
Please refer to my pbix file to see if it helps you.
Create a measure.
Measure =
IF (
MAX ( 'Table'[Cumple] ) > 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2022, 1, 1 ),
"CP5",
IF (
MAX ( 'Table'[Cumple] ) > 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2020, 12, 30 ),
"CP4",
IF (
MAX ( 'Table'[Cumple] ) > 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2017, 1, 1 ),
"CP2",
IF (
MAX ( 'Table'[Cumple] ) > 60
&& MAX ( 'Table'[Cumple] ) < 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2022, 1, 1 ),
"CP4",
IF (
MAX ( 'Table'[Cumple] ) > 60
&& MAX ( 'Table'[Cumple] ) < 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2020, 1, 1 ),
"CP3",
IF (
MAX ( 'Table'[Cumple] ) > 60
&& MAX ( 'Table'[Cumple] ) < 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2017, 1, 1 ),
"CP1",
"Null"
)
)
)
)
)
)
Or create a column.
Column =
IF (
'Table'[Cumple] > 90
&& 'Table'[Fecha] > DATE ( 2022, 1, 1 ),
"CP5",
IF (
'Table'[Cumple] > 90
&& 'Table'[Fecha] > DATE ( 2020, 12, 30 ),
"CP4",
IF (
'Table'[Cumple] > 90
&& 'Table'[Fecha] > DATE ( 2017, 1, 1 ),
"CP2",
IF (
'Table'[Cumple] > 60
&& 'Table'[Cumple] < 90
&& 'Table'[Fecha] > DATE ( 2022, 1, 1 ),
"CP4",
IF (
'Table'[Cumple] > 60
&& 'Table'[Cumple] < 90
&& 'Table'[Fecha] > DATE ( 2020, 1, 1 ),
"CP3",
IF (
'Table'[Cumple] > 60
&& 'Table'[Cumple] < 90
&& 'Table'[Fecha] > DATE ( 2017, 1, 1 ),
"CP1",
"Null"
)
)
)
)
)
)
If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @A7Russ ,
Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @A7Russ ,
Please refer to my pbix file to see if it helps you.
Create a measure.
Measure =
IF (
MAX ( 'Table'[Cumple] ) > 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2022, 1, 1 ),
"CP5",
IF (
MAX ( 'Table'[Cumple] ) > 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2020, 12, 30 ),
"CP4",
IF (
MAX ( 'Table'[Cumple] ) > 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2017, 1, 1 ),
"CP2",
IF (
MAX ( 'Table'[Cumple] ) > 60
&& MAX ( 'Table'[Cumple] ) < 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2022, 1, 1 ),
"CP4",
IF (
MAX ( 'Table'[Cumple] ) > 60
&& MAX ( 'Table'[Cumple] ) < 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2020, 1, 1 ),
"CP3",
IF (
MAX ( 'Table'[Cumple] ) > 60
&& MAX ( 'Table'[Cumple] ) < 90
&& MAX ( 'Table'[Fecha] ) > DATE ( 2017, 1, 1 ),
"CP1",
"Null"
)
)
)
)
)
)
Or create a column.
Column =
IF (
'Table'[Cumple] > 90
&& 'Table'[Fecha] > DATE ( 2022, 1, 1 ),
"CP5",
IF (
'Table'[Cumple] > 90
&& 'Table'[Fecha] > DATE ( 2020, 12, 30 ),
"CP4",
IF (
'Table'[Cumple] > 90
&& 'Table'[Fecha] > DATE ( 2017, 1, 1 ),
"CP2",
IF (
'Table'[Cumple] > 60
&& 'Table'[Cumple] < 90
&& 'Table'[Fecha] > DATE ( 2022, 1, 1 ),
"CP4",
IF (
'Table'[Cumple] > 60
&& 'Table'[Cumple] < 90
&& 'Table'[Fecha] > DATE ( 2020, 1, 1 ),
"CP3",
IF (
'Table'[Cumple] > 60
&& 'Table'[Cumple] < 90
&& 'Table'[Fecha] > DATE ( 2017, 1, 1 ),
"CP1",
"Null"
)
)
)
)
)
)
If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
11 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |