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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Lanceometer
Frequent Visitor

ALLSELECTED but include other filter

Hi Folks,

 

I have a problem with the VALUES() fuction.

 

I am creating a linechart showing a price-index. So the chart always starts at 1 and e.g. goes down to 0.98 when the price drops by 2%.

I am doing this for every my materials and aggregate an average to show this aggregated line.

 

So in short I want to do this:

per Material divide the price by the first price

 

My Dax formula looks like this:

Freight Surcharge Index =

AVERAGEX(

    VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Material No])

    ,

    DIVIDE(

        SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge])

        ,

        CALCULATE(

            // Here it ignores the VALUES Grouping

            FIRSTNONBLANKVALUE(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt],SELECTEDVALUE(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge]) )

            ,ALLSELECTED(DIM_Calendar[Date])

        )

    )

)
 
unfortunately in the CALCULATE part it seems to ignore the grouping by [Material No]
Propably because of the ALLSELECTED(DIM_Calendar[Date])
But I need this to excape the Date Dimension in the chart and get the first value.
 
How can I escape the Date Dimension in the Chart but keep the grouping of [Material No]?

 

2 ACCEPTED SOLUTIONS

@Lanceometer , Try using EARLIER than

 

dax
Freight Surcharge Index =
AVERAGEX(
VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Material No]),
DIVIDE(
SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge]),
CALCULATE(
FIRSTNONBLANK(
AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge],
AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt]
),
REMOVEFILTERS(DIM_Calendar[Date]),
VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Material No])
)
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

Adding VALUES() to the Calculate part did the trick!

 

So now the correct formula is:

 

Freight Surcharge Index = 

AVERAGEX(

    VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Granularity])

    ,

    DIVIDE(

        SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge])

        ,

        CALCULATE(

            FIRSTNONBLANKVALUE(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt],SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge]))

            ,

            ALLSELECTED(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt])

            , VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Granularity])

        )

    )

)
 
which results in this

Lanceometer_0-1741776222059.png



Thank you!

 

View solution in original post

4 REPLIES 4
bhanu_gautam
Super User
Super User

@Lanceometer , Try using

dax
Freight Surcharge Index =
AVERAGEX(
VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Material No]),
DIVIDE(
SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge]),
CALCULATE(
FIRSTNONBLANKVALUE(
AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt],
SELECTEDVALUE(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge])
),
REMOVEFILTERS(DIM_Calendar[Date])
)
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thank you for your suggestion.

Unfortunately the result is the same

@Lanceometer , Try using EARLIER than

 

dax
Freight Surcharge Index =
AVERAGEX(
VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Material No]),
DIVIDE(
SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge]),
CALCULATE(
FIRSTNONBLANK(
AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge],
AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt]
),
REMOVEFILTERS(DIM_Calendar[Date]),
VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Material No])
)
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Adding VALUES() to the Calculate part did the trick!

 

So now the correct formula is:

 

Freight Surcharge Index = 

AVERAGEX(

    VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Granularity])

    ,

    DIVIDE(

        SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge])

        ,

        CALCULATE(

            FIRSTNONBLANKVALUE(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt],SUM(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Freight Surcharge]))

            ,

            ALLSELECTED(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Report Dt])

            , VALUES(AML_PRICE_DATA_FACT_PURCHASING_PRICES[Granularity])

        )

    )

)
 
which results in this

Lanceometer_0-1741776222059.png



Thank you!

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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