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
deepvibha
Advocate II
Advocate II

Value summation by date

Hello,

 

I have a table as follows:

 

DateDepartmentReceivedWithin 24 hrsWithin 48 hrs
07-11-16Cornea723
07-11-16Glaucoma1032
07-11-16Retina843
07-11-16Cataract812
14-11-16Cornea1051
14-11-16Glaucoma1033
14-11-16Retina741
14-11-16Cataract822

 

The need is to have % of requests resolved within 24 hrs and 48 hrs, by department and date. For example:

For date 07-11-16 and Cornea department, 29% requests are resolved within 24hrs (2 divided by 7) and 43% requests are resolved within 48hrs (3 divided by 7).

 

I have imported the table in PBI and have unpivoted the columns, which looks as follows:

OP.png

 

I am also trying to create a column "Cornea24hrs" as seen in the figure, which is not successful.

 

Your help by way of detailed steps would be much appreciated.

 

Thanks a ton.

2 ACCEPTED SOLUTIONS

Hi @deepvibha

 

Just change the measures as follows and rest remaining the same as my previous reply

 

Create Measures - SumReceived, Sum24Hrs, Sum48Hrs as follows

    SumReceived = Calculate(sum (FactTable[Received]),FactTable[Attribute] = "Received")

    Sum24Hrs = Calculate(sum (FactTable[Received]),FactTable[Attribute] = "Within 24 Hrs")

    Sum48Hrs = Calculate(sum (FactTable[Received]),FactTable[Attribute] = "Within 48 Hrs")

 

This should work.

 

If this works please accept it as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

Hi @deepvibha

 

You will not be ablt to expactly replicate the excel output in Power BI.

 

There are two approaches possible.

 

1. Create a column called DateByDepartment =  Format([TransDate],"DD/MM/YYYY") & "-" & [Department]

2. Use this as a x-axis and then the measures 24hrs% and 48hrs% as Y-axis.

 

The out put will look like

 

                                 

 

                     

Capture.GIF

 

The x-axis will look like

                         Capture.GIF

Very close to Excel

 

The second approach is to create a hierarchy

1. Right click on the Date column of your table and select NewHierarchy

2. Drag the Department also under this.

3. Rename this hierarchy as TransDateDepartment

4. Use this as x-axis and the measures as y-axis.

5. The chart will initially look like

    Capture.GIF

6. Click on the weighing scale like icon you will see the output as

 

Capture.GIF

 

 When you click on the two down arrows icon you will get it at Department level.

 

 

If this works give additonal KUDOS.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

8 REPLIES 8
CheenuSing
Community Champion
Community Champion

Hi @deepvibha

 

Please try the following steps :

 

1. Create Measures - SumReceived, Sum24Hrs, Sum48Hrs as follows

    SumReceived = Sum(FactTable[Received])

    Sum24Hrs = sum (FactTable[Within 24 hrs])

    Sum48Hrs = sum (FactTable[Within 48 hrs])

 

2. Now create the measure %24Hrs, %48Hrs

   %24hrs = divide ([Sum24Hrs],[SumReceived])

   %48hrs = divide ([Sum48Hrs],[SumReceived])

 

3. Make these two % measures as data type perccentage.

 

4. You should get what you wanted, see the screen shot.

 

Capture.GIF

 

If this works for you please accept it as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Thanks @CheenuSing

 

 

The solution given is for pivoted table.

 

 

I am looking for a solution for an unpivoted table.

 

Regards,

Deepak

Hi @deepvibha

 

Can you explain what you mean by unpivoted table and the output you desire.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Thanks for a spontenous reply @CheenuSing

 

As I understand, the pivoted table is as under:

 

DateDepartmentReceivedWithin 24 hrsWithin 48 hrs
07-11-16Cornea723
07-11-16Glaucoma1032
07-11-16Retina843
07-11-16Cataract812
14-11-16Cornea1051
14-11-16Glaucoma1033
14-11-16Retina741
14-11-16Cataract822

 

 

Whereas an unpivoted table is as under, which is the format for a database :

DateDepartmentAttributeReceived
07-11-16CorneaReceived7
07-11-16CorneaWithin 24 hrs2
07-11-16CorneaWithin 48 hrs3
07-11-16GlaucomaReceived10
07-11-16GlaucomaWithin 24 hrs3
07-11-16GlaucomaWithin 48 hrs2
07-11-16RetinaReceived8
07-11-16RetinaWithin 24 hrs4
07-11-16RetinaWithin 48 hrs3
07-11-16CataractReceived8
07-11-16CataractWithin 24 hrs1
07-11-16CataractWithin 48 hrs2
14-11-16CorneaReceived10
14-11-16CorneaWithin 24 hrs5
14-11-16CorneaWithin 48 hrs1
14-11-16GlaucomaReceived10
14-11-16GlaucomaWithin 24 hrs3
14-11-16GlaucomaWithin 48 hrs3
14-11-16RetinaReceived7
14-11-16RetinaWithin 24 hrs4
14-11-16RetinaWithin 48 hrs1
14-11-16CataractReceived8
14-11-16CataractWithin 24 hrs2
14-11-16CataractWithin 48 hrs2

 

So far as the data is pulled from Excel, we can have the % in Excel columns and there is no need of calculating it in PBI. But what is the same data is pulled from Database?

 

My requirement is to have the % of patients requests resolved within 24 hrs and 48 hrs, by date & department. 

 

For example, on "Date" 07-11-16 I have received 7 requests for "Cornea" department of which 2 were resolved withing 24 hrs ( 29%, 2 divided by 7) and 3 were resolved within 48 hrs (43%, 3 divided by 7)

 

Similarly, for all departments for 07-11-16 and for 14-11-16.

 

I hope I have put in my requirement more elaboratly. 

 

Regards,

Deepak

 

 

Hi @deepvibha

 

Just change the measures as follows and rest remaining the same as my previous reply

 

Create Measures - SumReceived, Sum24Hrs, Sum48Hrs as follows

    SumReceived = Calculate(sum (FactTable[Received]),FactTable[Attribute] = "Received")

    Sum24Hrs = Calculate(sum (FactTable[Received]),FactTable[Attribute] = "Within 24 Hrs")

    Sum48Hrs = Calculate(sum (FactTable[Received]),FactTable[Attribute] = "Within 48 Hrs")

 

This should work.

 

If this works please accept it as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Thanks a Ton @CheenuSing,

 

The solution worked.....

 

The next challenge is to have both "Department" by "Date". The graph should reflect all the departments against the given dates. Like the chart below, which is plotted in MS Excel.

 

ExcelChart.png

 

But when doing it in PBI, I am unable achieve the same results.

 

OP.png

 

Would appreciate help on this...

 

Regards,

Deepak

 

Hi @deepvibha

 

You will not be ablt to expactly replicate the excel output in Power BI.

 

There are two approaches possible.

 

1. Create a column called DateByDepartment =  Format([TransDate],"DD/MM/YYYY") & "-" & [Department]

2. Use this as a x-axis and then the measures 24hrs% and 48hrs% as Y-axis.

 

The out put will look like

 

                                 

 

                     

Capture.GIF

 

The x-axis will look like

                         Capture.GIF

Very close to Excel

 

The second approach is to create a hierarchy

1. Right click on the Date column of your table and select NewHierarchy

2. Drag the Department also under this.

3. Rename this hierarchy as TransDateDepartment

4. Use this as x-axis and the measures as y-axis.

5. The chart will initially look like

    Capture.GIF

6. Click on the weighing scale like icon you will see the output as

 

Capture.GIF

 

 When you click on the two down arrows icon you will get it at Department level.

 

 

If this works give additonal KUDOS.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

That worked @CheenuSing

Thanks...

Regards,

Deepak

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.