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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JustinDoh1
Post Prodigy
Post Prodigy

Filter option (in Calculate) to take Max range only

(Sorry, this is a duplicate question that I posted few days ago, but I am posting again because I did not get a solution).

 

am trying to create a calculated column where I originally had two ranges to bring in as condition.

I was able to create a calcuated column with both Min and Max range, but I would like to only use Max.

 

Here is an illustration:

Tables.png

 

I was able to use this DAX and it worked fine.

Measure =
   CALCULATE(
            VALUES(Star[Value]),
   FILTER(
       Star,
       Star[Min] <= Sum(Test[Test])
        && Star[Max] >= SUM(Test[Test])
    )
)

 

But, I would like to only use one column (Max) instead of using two columns (with Min).

Bottom is just an illustration..

 

MeasureNEW =
  CALCULATE(
           VALUES(Star[Value]),
  FILTER(
     Star,
     Star[Max] >= MAX(Test[Test]) ??
   )
)

 

How do I accomplish it?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

[Measure] =
IF( HASONEVALUE( Test[Facility] ),
    var CurrentTestValue = SELECTEDVALUE( Test[Test] )
    return
        CALCULATE(
            SELECTEDVALUE( Star[Value] ),
            // This TOPN should return
            // just one row if everything
            // is correctly and logically
            // built and this, in turn, will
            // make only one Value be visible
            // in the context, hence SELECTEDVALUE
            // will return only one value as it
            // should be.
            TOPN(1,
                FILTER(
                    ALL( Star ),
                    CurrentTestValue <= Star[Max]
                ),
                Star[Max],
                ASC
            )
        )
)

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

[Measure] =
IF( HASONEVALUE( Test[Facility] ),
    var CurrentTestValue = SELECTEDVALUE( Test[Test] )
    return
        CALCULATE(
            SELECTEDVALUE( Star[Value] ),
            // This TOPN should return
            // just one row if everything
            // is correctly and logically
            // built and this, in turn, will
            // make only one Value be visible
            // in the context, hence SELECTEDVALUE
            // will return only one value as it
            // should be.
            TOPN(1,
                FILTER(
                    ALL( Star ),
                    CurrentTestValue <= Star[Max]
                ),
                Star[Max],
                ASC
            )
        )
)

@Anonymous 

Sorry this is late response.

But I am curious the purpose of having this column - Star[Max]?

 

),
Star[Max],
ASC
)

 

Is this just for "Sort by Star[Max] ASC"?

 

Thanks. 

 

 

Anonymous
Not applicable

TOPN

 

@Anonymous 

Thank you for your feedback. I guess you meant Star[Max],
ASC replaces the functionality of TOPN. 

Fowmy
Super User
Super User

@JustinDoh1 

You cannot use VALUES(Star[Value]) as the 1st argument for CALCULATE, it has to return a single value or be an aggregation like sum, average...ets.

If you want to return the count, for example, do it this way

MeasureNEW = 
  CALCULATE(
           COUNTROWS(VALUES(Star[Value])),
  FILTER(
     Star,
     Star[Max] >= EARLIER(Test[Test]) 
    )
)

 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy 

I am getting this message.

Earlier.png

@JustinDoh1 

 

You wanted a Calculated Column, I think you are trying as a measure.
Add  as a column

Fowmy_0-1619469716846.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.