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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Anonymous
Not applicable

Active cases Logic

Hello all,

I have active cases count in Line chart in PBI, when I drill down to Month level I can see each Month's Active cases count, but when I drill up the whole year active cases should be the Count which is there for december month, it should not be summation all months and showing for the Year 
Below is my active cases count for year 2023

Bharathi_99_0-1713094701994.png



when I drill up to Year level the active cases for 2023 should be the 9,627 which is there for December month

ACTIVE CASES COUNT_ = COUNT(' Active Cases Lists_'[CASE_KEY])

In my data for Active Cases Lists_ table I'll be having two columns, FIRST_DAY_MONTH , CASE_KEY

FIRST_DAY_OF_MONTHCASE_KEY
1/1/20231052
1/2/20231056
1/1/20231176
1/3/20231189
1/4/20231052

 


Help me Thanks!!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous Try the following. PBIX is attached below signature.

Measure = 
    VAR __LastDate = MAX('Table'[FIRST_DAY_OF_MONTH])
    VAR __LastNumber = SUMX(FILTER('Table', [FIRST_DAY_OF_MONTH] = __LastDate), [CASE_KEY])
    VAR __Result = IF(HASONEVALUE( 'Table'[FIRST_DAY_OF_MONTH] ), SUM('Table'[CASE_KEY]), __LastNumber)
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Anonymous Try the following. PBIX is attached below signature.

Measure = 
    VAR __LastDate = MAX('Table'[FIRST_DAY_OF_MONTH])
    VAR __LastNumber = SUMX(FILTER('Table', [FIRST_DAY_OF_MONTH] = __LastDate), [CASE_KEY])
    VAR __Result = IF(HASONEVALUE( 'Table'[FIRST_DAY_OF_MONTH] ), SUM('Table'[CASE_KEY]), __LastNumber)
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hello @Greg_Deckler ,

It's Working!!!
Thanks a lot....

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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