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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Measure context issue

Hello Everyone,

 

I am coming to you guys because I have an issue regarding a measure that I was not able to solve yet:

 

QinglongPR_0-1643907052924.png

 

What I would like is to filter Date TO Compare (FIELD of TABLE1) with the Non Context Date (Measure with ALLSELECTED(TABLE1)).

I am doing the following command: 

 

Max TEST 3 = CALCULATE(DISTINCTCOUNT(TABLE1.FIELD1), FILTER(TABLE1, TABLE1.DateToCompare <= TABLE1.NonContextDate))

 

However, it seems the Context Date is used instead of Non Context Date.

Here the result:

 

QinglongPR_1-1643907397560.png

 

Thank you, in advance, for your help.

 

 

Regards,

Thomas

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

NonContextDate = CALCULATE(MAX('TABLE1'[Context Date]),ALLSELECTED(TABLE1))

ALLSELECTED will cause some problem if you use it directly. You can try ALL function or you can try this code.

Max TEST 3 =
VAR _ADD =
    ADDCOLUMNS ( TABLE1, "NonContextDate", [NonContextDate] )
RETURN
    COUNTAX ( _ADD, [NonContextDate] )

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

Not clear what your actual issue is. What is the expected outcome?

 

Max TEST 3 = CALCULATE(DISTINCTCOUNT(TABLE1.FIELD1), FILTER(ALL(TABLE1), TABLE1.DateToCompare <= TABLE1.NonContextDate))
Anonymous
Not applicable

Hello @lbendlin,

 

Thank you for your time.

Expected outcome should be for the last row 1 instead of BLANK.any

NonContextDate = CALCULATE(MAX(ContextDate), ALLSELECTED(TABLE1))

But It seems it ignored the ALLSELECTED within Max TEST 3 measure.

 

 

Regards,

Thomas

Hi @Anonymous ,

 

NonContextDate = CALCULATE(MAX('TABLE1'[Context Date]),ALLSELECTED(TABLE1))

ALLSELECTED will cause some problem if you use it directly. You can try ALL function or you can try this code.

Max TEST 3 =
VAR _ADD =
    ADDCOLUMNS ( TABLE1, "NonContextDate", [NonContextDate] )
RETURN
    COUNTAX ( _ADD, [NonContextDate] )

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @Anonymous ,

 

NonContextDate = CALCULATE(MAX('TABLE1'[Context Date]),ALLSELECTED(TABLE1))

ALLSELECTED will cause some problem if you use it directly. You can try ALL function or you can try this code.

Max TEST 3 =
VAR _ADD =
    ADDCOLUMNS ( TABLE1, "NonContextDate", [NonContextDate] )
RETURN
    COUNTAX ( _ADD, [NonContextDate] )

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.