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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
rmeng1975
Regular Visitor

Measure to filter a table with last date values

https://1drv.ms/u/s!Am7PNkfu1RRdgrp4ixgtjrtJP22N_w?e=86giCO 
The objective is if I don´t filter the date slicer by default the table shows the last day activations (last day = 06/02/2024 and Type ="Active"):

DateTypeNameStateOriginQuantity

07/02/2024ParqAnual CampanhaActivo 72
07/02/2024Parq+ AnualActivo 13
07/02/2024Parqcanal +Activo 825
07/02/2024ParqAnual CampanhaActivo 6
07/02/2024Parq+ AnualActivo 313
07/02/2024Parqcanal +Activo 19
06/02/2024Parq+ AnualActivo 308
06/02/2024Parq+ AnualActivo 13
06/02/2024ParqAnual CampanhaActivo 6
06/02/2024ParqAnual CampanhaActivo 71
06/02/2024Activecanal + UFE3
06/02/2024Activecanal + APP/ Web1
06/02/2024Activecanal + Box7
06/02/2024Unactive+ Anual Outros1
06/02/2024Parqcanal +Activo 819
06/02/2024Parqcanal +Activo 19
05/02/2024Activecanal + UFE2
05/02/2024Activecanal + APP/ Web2
05/02/2024Activecanal + Box3
05/02/2024Active+ Anual Box1
05/02/2024UnactiveAnual Campanha Outros1
05/02/2024Unactivecanal + Outros5
05/02/2024Parqcanal +Activo 823
05/02/2024Parqcanal +Activo 18
05/02/2024Parq+ AnualActivo 314
05/02/2024Parq+ AnualActivo 13
05/02/2024ParqAnual CampanhaActivo 6
05/02/2024ParqAnual CampanhaActivo 72
04/02/2024Parqcanal +Activo 818
04/02/2024Activecanal + APP/ Web1
04/02/2024Activecanal + Box1
04/02/2024Unactive+ Anual Outros1
04/02/2024Unactivecanal + Outros2
04/02/2024Active+ Anual APP/ Web 

I have created a measure give me the correct total but show all dates   when only 06/02/2024 should appear:

 

 

 

 

#Last Date Activations = 
VAR _SelectedDate = 
CALCULATE ( MAX ( Canal[Date] ), 'Canal'[Type] = "Active" )
RETURN
    IF (
        ISFILTERED ( 'Date'[Date] ),
        [# Total Activations],
        CALCULATE (
            [# Total Activations],
            Canal,
             Canal[date] = _SelectedDate
        )
    )

 

 

 

The result shoul be a table like this :
DateTypeNameStateOriginQuantity

06/02/2024Activecanal + Box7
06/02/2024Activecanal + APP/ Web1
06/02/2024Activecanal + UFE3

 

thanks

1 ACCEPTED SOLUTION
talespin
Solution Sage
Solution Sage

hi @rmeng1975 ,

 

Please try this.

Step1 : Create below measure.

Step2: Set a filter on Table visual as shown in screenshot.

 

Create this measure

IsFiltered =
VAR _IsFilteredDate = SELECTEDVALUE('Date'[Date])
VAR _IsFilteredCanalDate = SELECTEDVALUE(Canal[Date])
VAR _LastActivatedDate = CALCULATE([# Last Date Activated], REMOVEFILTERS(Canal))
VAR _LastDateActivations = [#Last Date Activations]
RETURN IF(
            ISBLANK(_IsFilteredDate),
            IF(_IsFilteredCanalDate = _LastActivatedDate && NOT(ISBLANK(_LastDateActivations)), 1 , 0 ),
            1
)
 
talespin_0-1707802452380.png

 

View solution in original post

5 REPLIES 5
talespin
Solution Sage
Solution Sage

hi @rmeng1975 ,

 

Please try this.

Step1 : Create below measure.

Step2: Set a filter on Table visual as shown in screenshot.

 

Create this measure

IsFiltered =
VAR _IsFilteredDate = SELECTEDVALUE('Date'[Date])
VAR _IsFilteredCanalDate = SELECTEDVALUE(Canal[Date])
VAR _LastActivatedDate = CALCULATE([# Last Date Activated], REMOVEFILTERS(Canal))
VAR _LastDateActivations = [#Last Date Activations]
RETURN IF(
            ISBLANK(_IsFilteredDate),
            IF(_IsFilteredCanalDate = _LastActivatedDate && NOT(ISBLANK(_LastDateActivations)), 1 , 0 ),
            1
)
 
talespin_0-1707802452380.png

 

rmeng1975
Regular Visitor

It is in the PBIX shared link. But here it is 

# Total Activations =
CALCULATE ( [# Quantity], Canal[Type] = "Active" )
talespin
Solution Sage
Solution Sage

hi @rmeng1975 ,

 

Please share this measure "[# Ativação]"

lbendlin
Super User
Super User

 

Measures cannot return tables, they can only return scalar values.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Thanks for the feedback, I know Measures cannot return tables but the purpose is to use the measure inside the table and filter it. Filter bythe last date and is active.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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