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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Indexing based on value

Hi all,

 

With the corona virus threat going on I've been working with some of the data coming from Johns Hopkins University. The main page is here: https://github.com/CSSEGISandData/COVID-19

 

One of the charts I am trying to create is here below where they index all countries to start their day 1 from when their Confirmed cases is above 100.

 

grattan.png

 

 

If we focus particularly on the Confirmed cases CSV file (raw path accessible here: https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_ti...) does anyone know how to recreate this using Power BI?

 

If you're interested in the app I've built, I have made it public and am regularly updating it with posts on Linkedin. Will soon transfer and consolidate all this to GitHub.

 

I would really like to create the charts above as people I think would be very interested in these charts if we could make them interactive.

 

In the app I've built I am pulling the data in directly from the CSV listed on the JHU GitHub but happy if someone has a solution that works off directly downloading a CSV too.

 

Please help.

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous 

 

Something went wrong with my complex measures, so I changed the dax to create 2 calculated columns, gladly they are less complex and straightforward. Hope this is what you are looking for.

 

 

Total #cases by country by dates = 
CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Country/Region]=EARLIER('Table'[Country/Region])),'Table'[Period]=EARLIER('Table'[Period]))

Days since 100th case column = 
Var Date100casesbycountry = CALCULATE(MIN([Period]), FILTER('Table','Table'[Country/Region]=EARLIER('Table'[Country/Region])),FILTER('Table','Table'[Total #cases by country by dates]>=100))
Return DATEDIFF(Date100casesbycountry,[Period],DAY)

 

 

Pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/paul_qiuyunus_onmicrosoft_com/EbTiAZpmovJGph_ov9Rf...

 

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

@Anonymous 

 

Something went wrong with my complex measures, so I changed the dax to create 2 calculated columns, gladly they are less complex and straightforward. Hope this is what you are looking for.

 

 

Total #cases by country by dates = 
CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Country/Region]=EARLIER('Table'[Country/Region])),'Table'[Period]=EARLIER('Table'[Period]))

Days since 100th case column = 
Var Date100casesbycountry = CALCULATE(MIN([Period]), FILTER('Table','Table'[Country/Region]=EARLIER('Table'[Country/Region])),FILTER('Table','Table'[Total #cases by country by dates]>=100))
Return DATEDIFF(Date100casesbycountry,[Period],DAY)

 

 

Pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/paul_qiuyunus_onmicrosoft_com/EbTiAZpmovJGph_ov9Rf...

 

Paul Zheng
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 @Anonymous  and @Greg_Deckler ... your posts were so timely and so helpful. I've been busy the last day and a half but the latter post fit the bill well enough. 

 

I have used this to look at other types of cases and look at other analysis too. 

 

cheers

 

Mark

Greg_Deckler
Community Champion
Community Champion

I didn't have time to look at the data yet, but perhaps a columm like this:

 

Days since 100th case column =
  VAR __Table = FILTER('Table',[Country] = EARLIER([Country])
  VAR __Date = 'Table'[Date]
  VAR __Table1 = 
      ADDCOLUMNS(
        __Table,
       "__Cases",
       SUMX(__Table,[Date] <= EARLIER([Date]),[Cases Per Day])
  VAR __100Day = MINX(FILTER(__Table1,[Cases] >= 100),[Date])
  VAR __Days = (__Date - __100Day) * 1.
RETURN
  IF(__Days < 0,BLANK(),__Days)

 



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!:
DAX For Humans

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

Thanks @Greg_Deckler  will try that

 

Anonymous
Not applicable

Hi Greg,

 

Built a small demo file that pulls from the raw CSV on gitbhub. You can get it off my Google Drive: https://drive.google.com/open?id=18OxFHjXiWbAiOHw0X0jUkYLS5C0iUocL 

 

tried your formula but could not get it to work. Can you please take a look? Or anyone else who might know, feel free to take a look?

 

Would be great to solve this.

 

Thanks everyone!!

 

OK, @Anonymous I hadn't looked at the data and I'm lazy so I didn't test anything. Some syntax errors to be sure. Did this:

 

Days since 100th case column = 
  VAR __Table = FILTER('time_series_19-covid-Confirmed',[Country/Region] = EARLIER([Country/Region]))
  VAR __Date = 'time_series_19-covid-Confirmed'[Period]
  VAR __Table1 = 
      ADDCOLUMNS(
        __Table,
        "__Cases",
        SUMX(FILTER(__Table,[Period] <= EARLIER([Period])),[Value])
      )
  VAR __100Day = MINX(FILTER(__Table1,[__Cases] >= 100),[Period])
  VAR __Days = (__Date - __100Day) * 1.
RETURN
  IF(__Days < 1,BLANK(),__Days)

PBIX is attached below. You have lots of 1's due to province/state.

 

 



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors