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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Add column in visual table that checks if row is before or after selected calendar date

Hi,

 

I have a problem where I'm trying to add a column to my visual table that checks if the last date for an id is before or after date I select in a slicer. This slicer does not filter the table because I would like to keep all rows, but I wan't a column that checks if the date selected in slicer is before or after row date. 

 

I have tried using selectedvalue to get this working, but it's not, Does anyone have a nice workaround for this?

 

PBISea_0-1601201904231.png

 

Thanks!

 

1 ACCEPTED SOLUTION

Hi, @Anonymous , the cause of issue lies in the evaluation context of measures.

Each row of viz produces a filter context, i.e. ID=1, and this viz is separated from being filer by the slicer; then the only ID=1 is the only filter context for measure [calendar date], which evaluates to "9/17/2020".

A simple solution is to create a separate date table used as slicer and keep normal filters as well. Pls refer to attached file for more details.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , you may use a measure to record the selected date from the slicer

Date Selected = SelectedValue( Calendar[Calendar Date] )

then compare each row with the value of this measure.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi @CNENFRNL ,

 

No, this is not working, the screenshot you see, calendar date is using the selected value, then I use that in the "after calendar date"

Seems that since I don't filter the table, the selectedvalue is not filtered either..

Hi, @Anonymous , the screenshot seems ok for me 🤔

A simple means to debug is to put that measure in the viz to check which date on earth is used in the calculation for "after calendar date".

With an attachment of mockup file, your issue would be way much faster to get solved.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi @CNENFRNL 

 

I have uploaded a mock pbix file here: https://gofile.io/d/itKrHR

 

Since interaction with the table and my calendar slicer is off, not sure it would work to put it into the table. 

Hi, @Anonymous , the cause of issue lies in the evaluation context of measures.

Each row of viz produces a filter context, i.e. ID=1, and this viz is separated from being filer by the slicer; then the only ID=1 is the only filter context for measure [calendar date], which evaluates to "9/17/2020".

A simple solution is to create a separate date table used as slicer and keep normal filters as well. Pls refer to attached file for more details.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi @CNENFRNL ,

 

Works great, thanks!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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