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
YunJ
Post Prodigy
Post Prodigy

Wrong result when putting different date.

Hi,

I wrote a measure like following:

When I put "Start Date" in the table, the result is correct. But for the bottom two tables, which I put "YearMonth" and "YearWeek" in the table, the result is not correct. Any solution to fix this?

 

Thanks a lot for your help!

Capture.PNG

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @YunJ ,

 

To my understanding, try to create your measure like so:

8 (2) =
CALCULATE (
    SUM ( timetest[Sales] ),
    FILTER (
        ALLSELECTED ( timetest ),
        timetest[Land Date] IN VALUES ( timetest[Start Date] )
            && timetest[Presale_or not] = "Y"
    )
)

8.PNG

 

 

Best Regards,

Icey

 

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

8 REPLIES 8
Icey
Community Support
Community Support

Hi @YunJ ,

 

To my understanding, try to create your measure like so:

8 (2) =
CALCULATE (
    SUM ( timetest[Sales] ),
    FILTER (
        ALLSELECTED ( timetest ),
        timetest[Land Date] IN VALUES ( timetest[Start Date] )
            && timetest[Presale_or not] = "Y"
    )
)

8.PNG

 

 

Best Regards,

Icey

 

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

Hi @Icey 

Thanks for your great solution.

May I ask why you use ALLSELECTED function? and why you use 

timetest[Land Date] IN VALUES ( timetest[Start Date] )

rather than  

timetest[Land Date] = SELECTEDVALUE( timetest[Start Date] )

 

Thanks for your time and patience!

Yun 

Icey
Community Support
Community Support

Hi @YunJ ,

 

1. I use ALLSELECTED() to Remove context filters from columns and rows in the current query, while retaining all other context filters or explicit filters. For details, please refer to this blog: The definitive guide to ALLSELECTED.

 

2. If use SELECTEDVALUE(), the expression only works when one record "selected". But use VALUES(), it will return a list of records.

 

 

Best Regards,

Icey

 

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

Thanks a lot @Icey ! I read the link and some source about ALLSELECTED. But I'm still wondering why we need to remove context filters from columns and rows? 

For every row it has a unique value right? So it doesn't ignore the row filters right?

(Sorry I'm new to power bi, and sorry if I make my question silly... just still confused about ALL family DAX although learn for some time..)

Capture.PNG

Icey
Community Support
Community Support

Hi @YunJ ,

 

ALLSELECTED( timetest ) removes all filters of timetest table, except those included on this report page.

And the expression below is the reason why [Start Date] and [Year Week] keep working as filters. You can try to delete it and the result will be different.

timetest[Land Date] IN VALUES ( timetest[Start Date] )

 

This may be a little difficult to understand. It is suggested to refer to some documents and videos.

document:

Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT

 

video:

The Main Difference Between ALL And ALLSELECTED - Power BI & DAX

 

 

Best Regards,

Icey

 

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

Thanks for your sharing @Icey 

parry2k
Super User
Super User

@YunJ why you are using allexcept function? Can you define what you are trying to achieve?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k 

 

I wrote allexcept(table[category]) to make my Category slicer can work. When I only used all(table), the Category slicer does not work.

 

Thanks

Yun

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.