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
Anonymous
Not applicable

2 measures with 2 distinct years not working

Hi folks,

 

I have a slicer from where I select 2 distinct years, imagine 2018 and 2020 and i want to compare 2 distinct measures, one for the context of 2018 and another one for 2020.

 

Any one know why isn't this working since there are 2 distinct measures for each context?

 

Thanks in advance for your help.

 

Capture.JPG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solved with this suggestion from another Post:

 

Prior Day Invoiced =
VAR PreviousBusinessDay = [Priorbusinessday]
RETURN
    CALCULATE (
        SUM ( 'Sales Ledger Transactions'[Net Sales] ),
        'Sales Ledger Transactions'[Fact Attributes.Source Sale Type Code] = "INVOICED",
        'Sales Ledger Transactions'[Date.Date] = PreviousBusinessDay
    )

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @Anonymous 

 

First check your N-X and X are showing correct values i.e 2018 and 2020.

Second remove all from filter section.

If issue still persist then share your dataset. I will check.

 

Thanks & regards,

Pravin Wattamwar

Anonymous
Not applicable

Remove that ALL or else you can add KEEPFILTERS Before "Filter".

 

For More About KEEPFILTERS -https://www.sqlbi.com/articles/using-keepfilters-in-dax/

 

Thanks & regards,

Pravin Wattamwar

az38
Community Champion
Community Champion

Hi @Anonymous 

try to replace your PROD_TAB[DATEVAL].[Year] to YEAR(PROD_TAB[DATEVAL])

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Thank you for your suggestion but didn't work either.

az38
Community Champion
Community Champion

@Anonymous 

it looks like it should be enough to use

 

= CALCULATE(
DISTINCTCOUNT(PROD_TAB[REF]);YEAR(PROD_TAB[DATEVAL])=[Yr_N-x]
)

 

or (it depends on your data model)

= CALCULATE(
DISTINCTCOUNT(PROD_TAB[REF]);YEAR(PROD_TAB[DATEVAL])=YEAR([Yr_N-x])
)

 

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

 

 

Doesn't work due to this:

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

Anonymous
Not applicable

Solved with this suggestion from another Post:

 

Prior Day Invoiced =
VAR PreviousBusinessDay = [Priorbusinessday]
RETURN
    CALCULATE (
        SUM ( 'Sales Ledger Transactions'[Net Sales] ),
        'Sales Ledger Transactions'[Fact Attributes.Source Sale Type Code] = "INVOICED",
        'Sales Ledger Transactions'[Date.Date] = PreviousBusinessDay
    )
Anonymous
Not applicable

Thank you for your assistance, but doesn't work neither using keepfilters, without ALL, with KEEPFILTERS and FILTER.

 

I've tried all the options and perhaps it's a question of dataset.

 

to simplify I explain my dataset to you, it's a date table and a a fact table joined by DateasInteger key on one to many both sides relation.

The measure is a distintcount of unique references on the fact table

the filter is based on the date table, but i've tried to filter based on the date column of the fact table and behaviour is the same. PBI is summing all rows from both years.

 

Thanks in advance for your help.

 

Kind regards,

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.

Top Solution Authors