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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.