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
NicoleTy
New Member

How to show percentage of count by different units?

Hi,

 

I'm new to PowerBI need some help figure this out. I have two tables t1 and t2 generated by a sql query from table t0 group by t0.TimeDuration:

 

The schema for t0,t1, t2 is:

t0:

|TimeDuration|Contry|type|Category|

 

t1:

|TimeInHours | CountByHours |Country |Type | Category

  < 1hr                   10                   USA      T1       C1

  1-2-hr                  20                   USA      T2       C1

  2-4-hr                  10                   USA      T2       C1

 

t2:

|TimeInDays | CountByDays |Country |Type |Category

     <1 day               10              USA   T1           C1

     <1 day                30             USA   T2           C1

 

Now I need to have 2 pie charts with percentage of total number of each each time duration(by hour and by day) on the same report, use can see the result based on filter specified like country, type or category.

 

Is this even possible to do with powerbi? Do I need to define some measure or create table relathionship to accomplish that?

 

Thanks in advance.

-Nicole 

4 REPLIES 4
Greg_Deckler
Super User
Super User

In Power Query, use the "Split" functionality for t1 and t2 to split them on the | character (use Custom, |). You can import t1 into a table and then maybe append a second query to t2 or you could have them in separate tables and create measures that aggregate them.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Smoupre,

 

Can you give me an example of doing that?

 

-Nicole

In Query Editor, choose your column, go to Transform and in the "Text Column" area of the ribbon, choose Split Column button, By Delimitor, Custom, |. Default should be all occurrences. The resulting "M" code will look something like this:

 

= Table.SplitColumn(#"Changed Type","ranges",Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv),{"ranges.1", "ranges.2", "ranges.3", "ranges.4", "ranges.5"})

 

You can do this for both t1 in one query and get rid of t2 in that query (remove other columns).

 

Repeat for t2, removing t1 from this query but right after "Source" step, click "Append Queries" from "Combine" area of ribbon on the Home tab.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Unfortunately, that's not what I was asking.

 

I have the data already splitted and loaded correctly in PowerBI.

 

My question was how can I calculate the percentage of the count of hours in t1 and count of days in t2 filtered by different columns in one report.

 

Anyone can help?

 

 

 

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.