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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.