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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Filter by values with TRUE() to visualize

Hello everyone,

 

I want to give the user the ability to choose what to see on the datetime axis, currentDay, currentMonth or currentQuarter based on the date selection.

 

I created the following:

Screenshot 2020-11-18 123928.png

 

After that, I made a measure to connect the selections slider to filter only the values with TRUE() to show on the visual:

 

Dynamic Measure intervals = 
VAR SlicerID =  MAX('currents table'[ID]) 
RETURN
IF(
    ISFILTERED('currents table'[selects]),
    SWITCH(
        TRUE(),
        SlicerID = 1 , CALCULATE([Sum of My Value], FILTER('Data Table','Data Table'[currentDay]=TRUE())),
	 	SlicerID = 2 , CALCULATE([Sum of My Value],FILTER('Data Table','Data Table'[currentMonth]=TRUE())),
        SlicerID = 3 , CALCULATE([Sum of My Value],FILTER('Data Table','Data Table'[currentQuarter]=TRUE()))
        )
    )

 

Can somebody help me understand what i am doing wrong ?

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

I build a sample to have a test.

My sample table is as below, year/month/qtr columns are calculated columns.

Year = YEAR(Sheet9[Date])
Month = MONTH(Sheet9[Date])
Qtr = QUARTER(Sheet9[Date])

1.png

Date Table:

Date = CALENDARAUTO()

Select Table:

2.png

We can build a date before slicer by Date table, and a select slicer by Select Table.

Measure:

Sum of value = SUM(Sheet9[Value])
Measure = 
VAR _SelectStatus = 
    SELECTEDVALUE('Select'[Select])
VAR _SelectDate = 
    MAX('Date'[Date])
Return
IF(
    ISFILTERED('Select'[Select]),
    SWITCH(
        TRUE(),
        _SelectStatus="CurrentDay",IF(MAX(Sheet9[Date])=_SelectDate,1,0),
        _SelectStatus="CurrentMonth",IF(MAX(Sheet9[Year]) = YEAR(_SelectDate)&&MAX(Sheet9[Month])=MONTH(_SelectDate),1,0),
        _SelectStatus="CurrentQuarter",IF(MAX(Sheet9[Year]) = YEAR(_SelectDate)&&MAX(Sheet9[Qtr])=QUARTER(_SelectDate),1,0)
    )
)

Build a Table visual by Sheet9[Date], Sheet9[Value] and Sum of value measure.

Then we add Measure into the filter field in this table visual and set it to show items when value =1.

Result is as below.

Select "CurrentDay", Date = 2020/01/23

3.png

Select "CurrentMonth", Date = 2020/01/23

4.png

Select "CurrentQuarter", Date = 2020/01/23

5.png

You can download the pbix file from this link: Filter by values with TRUE() to visualize

 

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

6 REPLIES 6
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

I build a sample to have a test.

My sample table is as below, year/month/qtr columns are calculated columns.

Year = YEAR(Sheet9[Date])
Month = MONTH(Sheet9[Date])
Qtr = QUARTER(Sheet9[Date])

1.png

Date Table:

Date = CALENDARAUTO()

Select Table:

2.png

We can build a date before slicer by Date table, and a select slicer by Select Table.

Measure:

Sum of value = SUM(Sheet9[Value])
Measure = 
VAR _SelectStatus = 
    SELECTEDVALUE('Select'[Select])
VAR _SelectDate = 
    MAX('Date'[Date])
Return
IF(
    ISFILTERED('Select'[Select]),
    SWITCH(
        TRUE(),
        _SelectStatus="CurrentDay",IF(MAX(Sheet9[Date])=_SelectDate,1,0),
        _SelectStatus="CurrentMonth",IF(MAX(Sheet9[Year]) = YEAR(_SelectDate)&&MAX(Sheet9[Month])=MONTH(_SelectDate),1,0),
        _SelectStatus="CurrentQuarter",IF(MAX(Sheet9[Year]) = YEAR(_SelectDate)&&MAX(Sheet9[Qtr])=QUARTER(_SelectDate),1,0)
    )
)

Build a Table visual by Sheet9[Date], Sheet9[Value] and Sum of value measure.

Then we add Measure into the filter field in this table visual and set it to show items when value =1.

Result is as below.

Select "CurrentDay", Date = 2020/01/23

3.png

Select "CurrentMonth", Date = 2020/01/23

4.png

Select "CurrentQuarter", Date = 2020/01/23

5.png

You can download the pbix file from this link: Filter by values with TRUE() to visualize

 

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. 

 

Anonymous
Not applicable

Thank you for taking the time to help. Now I see what I was doing wrong

amitchandak
Super User
Super User

@Anonymous , what is the issue is facing ? Try this change

VAR SlicerID =  MAXX(allselected('currents table'),'currents table'[ID]) 

 

 

Anonymous
Not applicable

Thank you for responding, but its still dosent do the trick.

AlB
Super User
Super User

Hi @Anonymous 

Are

  'Data Table'[currentDay],

  'Data Table'[currentMonth]

  'Data Table'[currentQuarter]

calculated columns?

If so you need to use measures. Calc columns are not dynamic

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Anonymous
Not applicable

No they are calculated measure. currentday for example looks like this:

currentDay = SELECTEDVALUE('Data Table'[Date])>=MAXX(ALLSELECTED('Data Table'[Date]),[Date])-1 && SELECTEDVALUE('Data Table'[Date])>=MAXX(ALLSELECTED('Data Table'[Date]),[Date])
 
And give TRUE() only for today and FALSE() for all other days

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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