cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Calculate dynamic measure based on slicer selection

Hi Everyone,

 

I am total newbie for Power BI, just couple of days hands on. I have a problem that I have not been able to solve till now and I was wondering if you could help me?

 

I have used a slicer to select data to my clustered column chart. I used following measure to read slicer value (European syntax).

 

Selected =

CONCATENATEX(
ALLSELECTED('Table1'[Column]);
'Table1'[Column];
";"
)

 

My plan is to use Selected value in another measure to dynamically calculate the line value. I have used direct query to my SQL Server DB but that should not affect to these calculations.

 

I tried to use the Selected value in following formula:

 

Metrics1 = ABS(CALCULATE(MAX('FactTable'[Value]);'DimensionTable'[Column]=[Selected];LASTDATE('Dimension Date'[Calendar_Date]))/(CALCULATE(MIN('FactTable'[Value]);'DimensionTable'[Column]=[Selected];ALLSELECTED('Dimension Date'[Calendar_Date])))-1)

 

Error message: A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

Your help would be highly appreciated!

 

Regards,

 

JuhoP

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Calculate dynamic measure based on slicer selection

Hi @JuhoP,

 

Could you try the formula below to see if it works? Smiley Happy

Metrics1 =
VAR s = [Selected]
RETURN
    ABS (
        CALCULATE (
            MAX ( 'FactTable'[Value] );
            'DimensionTable'[Column] = s;
            LASTDATE ( 'Dimension Date'[Calendar_Date] )
        )
            / (
                CALCULATE (
                    MIN ( 'FactTable'[Value] );
                    'DimensionTable'[Column] = s;
                    ALLSELECTED ( 'Dimension Date'[Calendar_Date] )
                )
            )
            - 1
    )

 

Regards

View solution in original post

2 REPLIES 2
Highlighted
Microsoft
Microsoft

Re: Calculate dynamic measure based on slicer selection

Hi @JuhoP,

 

Could you try the formula below to see if it works? Smiley Happy

Metrics1 =
VAR s = [Selected]
RETURN
    ABS (
        CALCULATE (
            MAX ( 'FactTable'[Value] );
            'DimensionTable'[Column] = s;
            LASTDATE ( 'Dimension Date'[Calendar_Date] )
        )
            / (
                CALCULATE (
                    MIN ( 'FactTable'[Value] );
                    'DimensionTable'[Column] = s;
                    ALLSELECTED ( 'Dimension Date'[Calendar_Date] )
                )
            )
            - 1
    )

 

Regards

View solution in original post

Highlighted
New Member

Re: Calculate dynamic measure based on slicer selection

Hi!

 

Yes, it works beatifully! Thanks a million! 

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors