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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sentsara
Helper II
Helper II

DAX Expression for comparing rows

 

Hi ,

I need help on "Rate Level Current" DAX Expression to built.

 

Requirement:

Step:1 Take "current Forecast" Percentage value by applying filter on currrent "PM" Value 

step:2 check under which "Scenario Rate" its falling and map the minium "Rate Level Value". 

 

Pseudo logic:

IF Current Forecast > Scenario Rate then 1
IF CUrrent Forecast between Scenario Rate then take MIN of "RateLevel"
IF Current Forecast < Scenaro Rate then 9

 

below is dataset and i need to Write DAX Expression for " Rate Level Current". can you please help on this?

PMRate LevelScenario RateCurrent ForecastRate Level Current
CH_ABC167.52%62.94%6
CH_ABC266.05%62.94%6
CH_ABC365.51%62.94%6
CH_ABC464.47%62.94%6
CH_ABC564.46%62.94%6
CH_ABC661.52%62.94%6
CH_ABC759.51%62.94%6
CH_ABC857.66%62.94%6
CH_ABC90.00%62.94%6
CH_GDB191.93%86.88%4
CH_GDB289.40%86.88%4
CH_GDB389.28%86.88%4
CH_GDB485.27%86.88%4
CH_GDB584.25%86.88%4
CH_GDB677.28%86.88%4
CH_GDB777.27%86.88%4
CH_GDB876.23%86.88%4
CH_GDB90.00%86.88%4

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

I used this DAX statement to create a calculated column:

calc Rate Level Current = 
var currentPM = 'Table1'[PM]
var currentForecast = 'Table1'[Current Forecast]
var smallerScenarioRate =
CALCULATE(
    MAX('Table1'[Scenario Rate])
    ,FILTER(
        ALL('Table1')
        ,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] < currentForecast
    )
)
return
CALCULATE(
    MAX('Table1'[Rate Level])
    ,FILTER(
        ALL('Table1')
        ,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] = smallerScenarioRate
    )
)

This returns these values:

image.png

 

And here is a small PBIX file

 

Hopefully this is what you are looking for.

 

Regards

Tom

 

 

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey,

 

I used this DAX statement to create a calculated column:

calc Rate Level Current = 
var currentPM = 'Table1'[PM]
var currentForecast = 'Table1'[Current Forecast]
var smallerScenarioRate =
CALCULATE(
    MAX('Table1'[Scenario Rate])
    ,FILTER(
        ALL('Table1')
        ,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] < currentForecast
    )
)
return
CALCULATE(
    MAX('Table1'[Rate Level])
    ,FILTER(
        ALL('Table1')
        ,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] = smallerScenarioRate
    )
)

This returns these values:

image.png

 

And here is a small PBIX file

 

Hopefully this is what you are looking for.

 

Regards

Tom

 

 

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom,

Thanks for taking time and provided with good example. i forgot to say one more thing. Current Forecast is the calculated column which is defined in another Dataset.i think thats the reason circular dependency was detected error is thrown.

 

 

I'm getting error as : "Circular Dependency was detected:"

 

calc Rate Level Current =
var currentPM = 'Table1'[PM]
var currentForecast = 'Table1'[Current Forecast] -- it comes from QRI DATASET --UNDER QRI Dataset it has derived as caculated column


var smallerScenarioRate =
CALCULATE(
MAX('Table1'[Scenario Rate])
,FILTER(
ALL('Table1')
,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] < currentForecast
)
)
return
CALCULATE(
MAX('Table1'[Rate Level])
,FILTER(
ALL('Table1')
,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] = smallerScenarioRate
)
)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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