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
curious_monkey
Regular Visitor

Not able to calculate sum/count - Date Slider

I have a excel sheet with data like below

curious_monkey_0-1671663524289.png

my problem statement is very simple (with a small twist) - i want to create a small visual with a date slider and as i increase the date, it will show me the count (count of flag column) of all cities falling in that date range -- simple right.

 

now the problem part, the Cities whic have a INFRA code of UPGRADE should always be part of count and showuld not be effected by date slider: (Business Logic, we want to see the count of NEW cities added, UPGRADE means they existed before)

 

 To elleborate see below example:

 

CITIES ADDED UNTIL 12/3/2022 = 2 NEW + 8 UPGRADE = 10

CITIES ADDED UNTIL 12/5/2022 = 3 NEW + 8 UPGRADE = 11

CITIES ADDED UNTIL 12/8/2022 = 5 NEW + 8 UPGRADE = 13

 

So UPGRADE needs to be a constant, Count of UPBGRADE should only change, when there are new rows added with UPGRADE as a value.

 

Problem i am facing is that DATE SLIDER --> filter everything out by date filter and cannot seperate UPGRADE valued ROWS

 

I have tried to to seperate these two values by creating a measure using DAX (one measure taking count of values with only NEW, and one measure to count values with only UPGRADE) but that too get filtered by the DATE SLIDER??

 

what to do??

 

 

1 ACCEPTED SOLUTION
bolfri
Super User
Super User

Hi, 


Basic measure to sum flags:

Sum of flags = SUM('Sample'[FLAG])



To calculate upgrade constant you can use this measure:

Upgrade constant = CALCULATE([Sum of flags],ALL('Sample'),'Sample'[INFRA]="UPGRADE")

For new cities added it's:

Cities added = CALCULATE([Sum of flags],'Sample'[INFRA]="NEW")

Running totals:

Running total = 
var _maxdate = LASTDATE('Sample'[DATE])
var _upgrade = CALCULATE([Sum of flags],ALL('Sample'),'Sample'[INFRA]="UPGRADE")
var _new = CALCULATE([Sum of flags],'Sample'[INFRA]="NEW",FILTER(ALL('Sample'[DATE]),'Sample'[DATE]<=_maxdate))
return _upgrade + _new

 

Results:

bolfri_0-1671666869444.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
curious_monkey
Regular Visitor

@bolfri THANK YOU, THAT RESOLVED MY ISSUE

curious_monkey_0-1671721979615.png

 

AS YOU CAN SEE ABOVE, I AM ABLE TO USE THE RUNNING TOTAL IN MY CARD - HOWEVER (THIS IS NOT A PROBLEM) THE UPGRADE CONSTANT FOR ME DOSENT SHOW TOTAL UPGRADE LIKE YOURS?

Are you using a date field from that same table or do you use calendar for this?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




same table, no calender table used

Can you share a pbix file with that issue? eg via https://wetransfer.com/ or I can give you my email adress. Before that: this is sample file from me: https://we.tl/t-230s9HmCcL check if this is what you were looking for.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




bolfri
Super User
Super User

Hi, 


Basic measure to sum flags:

Sum of flags = SUM('Sample'[FLAG])



To calculate upgrade constant you can use this measure:

Upgrade constant = CALCULATE([Sum of flags],ALL('Sample'),'Sample'[INFRA]="UPGRADE")

For new cities added it's:

Cities added = CALCULATE([Sum of flags],'Sample'[INFRA]="NEW")

Running totals:

Running total = 
var _maxdate = LASTDATE('Sample'[DATE])
var _upgrade = CALCULATE([Sum of flags],ALL('Sample'),'Sample'[INFRA]="UPGRADE")
var _new = CALCULATE([Sum of flags],'Sample'[INFRA]="NEW",FILTER(ALL('Sample'[DATE]),'Sample'[DATE]<=_maxdate))
return _upgrade + _new

 

Results:

bolfri_0-1671666869444.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.