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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hellind
Frequent Visitor

Last Year Products Traded

Can some one help with the measure?

My data model is

[Dates] table as Calendar lookup Table.

[Products] as Products  lookupTable

'Volume SC' is the data table

 

This measure concatenates the product traded For Previous Fiscal Year = 2018, the products traded are zero.

For current Fiscal Year = 2019, the products traded are 'Stocks', for example.

This measure is supposed to return the products traded the PREVIOUS YEAR 2018 BUT it returns the products traded this year 2019. Seems the FILTER(ALL(DATES) is not working.

 

 

List of Products Category Traded:=

VAR ProductsLY = CALCULATETABLE(VALUES( PRODUCTS[ProductCategory]) ,

     FILTER( ALL(DATES), [Fiscal Year] = MAX(Dates[Fiscal Year]) - 1 ) ,

     FILTER ('Volume SC', [Traded Volume] > 0) )

 

RETURN CONCATENATEX(ProductslY, [ProductCategory], ",")

1 ACCEPTED SOLUTION

My data-model is a star schema.

[Products] is a Dimension table with a one-direction relationship flowing down to fact table 'Volume SC'

Therefore, the solution was, to use CROSSFILTER, the amemded code below works, during the execution of the code the filter will flow up back to Products table to concatenate the values of Product Category.

 

Thanks to everyone who tried to help.

 

 

 

List of Products Category Traded:=

VAR ProductsLY = CALCULATETABLE(VALUES( PRODUCTS[ProductCategory]) ,

     CROSSFILTER(PRODUCTS[Product], 'Volume SC'[Product], Both)

     FILTER( ALL(DATES), [Fiscal Year] = MAX(Dates[Fiscal Year]) - 1 ) ,

     FILTER ('Volume SC', [Traded Volume] > 0) )

View solution in original post

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @hellind ,

 

You should remove the relationship between 'DATES' table and 'Volume SC' table. Then, the formula should be modified similar to below.

List of Products Category Traded =
VAR ProductsLY =
    CALCULATETABLE (
        VALUES ( PRODUCTS[ProductCategory] ),
        FILTER (
            ALLSELECTED ( 'Volume SC' ),
            'Volume SC'[Fiscal Year]
                = MAX ( Dates[Fiscal Year] ) - 1
                && [Traded Volume] > 0
        )
    )
RETURN
    CONCATENATEX ( ProductslY, [ProductCategory], "," )

Best regards,

Yuliana Gu

 

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
GilbertQ
Super User
Super User

Hi there

Could it not be that you explained that in 2018 "The products traded are zero" and in your measure you are filtering out data where the Traded Volumne > 0?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

In the pivot filter, I have selected Fiscal Year = 2019

 

Therefore this measure is supposed to return for the previous year Fiscal Year = 2018

 

This line of code is supposed to look back one year:

 

FILTER (ALL(Dates),
(Dates[Fiscal Year]) = MIN(Dates[Fiscal Year]) - 1
)

 

 

But it is not taking back one year.

My data-model is a star schema.

[Products] is a Dimension table with a one-direction relationship flowing down to fact table 'Volume SC'

Therefore, the solution was, to use CROSSFILTER, the amemded code below works, during the execution of the code the filter will flow up back to Products table to concatenate the values of Product Category.

 

Thanks to everyone who tried to help.

 

 

 

List of Products Category Traded:=

VAR ProductsLY = CALCULATETABLE(VALUES( PRODUCTS[ProductCategory]) ,

     CROSSFILTER(PRODUCTS[Product], 'Volume SC'[Product], Both)

     FILTER( ALL(DATES), [Fiscal Year] = MAX(Dates[Fiscal Year]) - 1 ) ,

     FILTER ('Volume SC', [Traded Volume] > 0) )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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