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
Anonymous
Not applicable

Latest Value in Slicer

I have two tables (Dates and Demographics) of which there is a relationship in the dates column from both table.

From the Dates table, i have two different slicer, Month and Year, where multiple value could be selected.

JanFebMarAprMayJunJulAugSepOctNovDec

 

201820192020

 

The demographic data is build in this way:

DateI.DNationality
1/1/2018AAmerican
1/1/2018BJapanese
1/2/2018AAmerican
1/2/2018CKorean

 

I am trying to build a table to show the break down of headcount by nationality. 

I am using this measure to calculate the headcount: calculate(counta(I.D),filter(Demographic, demographic[date] = max(demographic[date])))

However, the result that i get is not what i wanted. 

For instance, Feb and 2018 is selected in the slicer, what the tables shows is:

NationalityHeadcount
Japanese1
American1
Korean1

where Japanese should not appear.

 

So right now i am trying to match the month(demographic[date]) year(demographic[date])= max([ selected month])max([selected year]) instead which i cannot seem to do it.

 

Please advice. 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Sorry. Please check if this is what you want:

headcount =
VAR LatestDate =
    MAXX ( ALL ( demographic ), demographic[Date] )
RETURN
    IF (
        ISFILTERED ( Dates[Year] ) || ISFILTERED ( Dates[Month] ),
        COUNT ( demographic[I.D] ),
        CALCULATE ( COUNT ( demographic[I.D] ), demographic[Date] = LatestDate )
    )

latest.gif

 

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

4 REPLIES 4
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Just as @amitchandak said, if you have created relationship between the two tables, you only need to create a simple measure.

 

headcount = COUNT(demographic[I.D])

 

na.gif

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

Hi @Icey , 

 

You got my issue wrong, what i want it to show is the data based on the latest date (without clicking on to the slicer showing 1/2/2018).  What you are showing me is the count of every nationality at hand.

So what i want the table to show is 1 american 1 korean when the slicer is not selected.


I want to show the audience of the report the most up to date info as it appear and should they want to see the other dates, they will then toggle around the slicer.

 

Thank you.

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Sorry. Please check if this is what you want:

headcount =
VAR LatestDate =
    MAXX ( ALL ( demographic ), demographic[Date] )
RETURN
    IF (
        ISFILTERED ( Dates[Year] ) || ISFILTERED ( Dates[Month] ),
        COUNT ( demographic[I.D] ),
        CALCULATE ( COUNT ( demographic[I.D] ), demographic[Date] = LatestDate )
    )

latest.gif

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@Anonymous , If you date table if Date joined on date and using month and year from there only Count should do.

 

calculate(counta([I.D]))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

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.