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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
jambopriti
Helper I
Helper I

Need Help in the Calculation - If-Then_Else or alternatives

Hi,

I have the below request (testdata) is included. Please guide. Thanks.

I have these requirements and need to create the visual like below. Please guide. Thank you.

Calculate the Readmits:

    • Get total number of records as the denominator
  • Filter Same Level = “yes”
    • Days 0-30, Count the NO. of records
    • Days 31-60, Count the NO. of records
    • Days 61-90, Count the NO. of records
    •  
    • Days 91-365, Count the NO. of records
  • Divide the readmit in each category by the total no. of records. 

My result should be

    • Days 0-30 – 2 readmits
    • Days 31-60 – 0 readmit
    • Days 61-90 – 1 readmit
    • Days 91-365 – 3 readmits

Visual:

 Re-Admit Data

 

30 Day

60Day

90 Day

1 year

Total Readmissions

2

0

1

3

Percent Readmit

4.44%

0

2.22%

6.67%

 

Data:

idservicedatesame_levelDays
6790894RC1/22/2025No 
6803017RC3/3/2025Yes102
6783644RC1/19/2025Yes317
6811454RC3/15/2025No 
6815434RC3/26/2025No 
6813452RC3/10/2025No 
6810816RC3/21/2025No 
6806671RC2/21/2025No 
6805507RC3/7/2025No 
6802936RC2/26/2025No 
6798416RC2/25/2025No 
6791776RC2/2/2025No 
6782626RC1/11/2025No 
6781434RC1/10/2025No 
6803862RC3/5/2025No 
6789267RC1/21/2025No 
6826130RC3/30/2025No 
6814711RC3/20/2025No 
6801497RC2/22/2025No 
6798936RC2/25/2025No 
6795489RC2/5/2025No 
6794939RC2/13/2025No 
6780098RC1/10/2025No 
6784350RC1/22/2025No 
6810948RC3/17/2025No 
6797179RC2/24/2025No 
6797303RC2/24/2025No 
6804658RC2/28/2025No 
6804356RC3/1/2025No 
6800258RC2/27/2025No 
6808375RC2/17/2025No 
6799512RC2/26/2025No 
6806709RC3/16/2025No 
6797819RC2/19/2025No 
6821183RC3/26/2025No 
6798021RC2/23/2025No 
6797813RC2/19/2025No 
6788436RC1/29/2025Yes8
6788609RC1/29/2025Yes82
6798616RC2/15/2025No 
6792929RC2/2/2025No 
6792330RC2/10/2025No 
6816231RC3/10/2025No 
6816150RC3/28/2025Yes19
6791245RC1/30/2025Yes215
1 ACCEPTED SOLUTION

Hi @jambopriti ,

 

Thank you for reaching out to Microsoft Fabric Community Forum.

Please use the following DAX measures.

 

Total Records(Readmits) = COUNTROWS('ReAdmit DATA')

 

Readmit 0-30 =
CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] >= 0,
    'ReAdmit DATA'[Days] <= 30
)
 
Readmit 31-60 =
if(ISBLANK(CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 30,
    'ReAdmit DATA'[Days] <= 60
)),0,cALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 30,
    'ReAdmit DATA'[Days] <= 60
))
 
 
Readmit 61-90 =
CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 60,
    'ReAdmit DATA'[Days] <= 90
)
 
Readmit 91-365 =
CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 90,
    'ReAdmit DATA'[Days] <= 365
)
 
 
Percent 0-30 = DIVIDE([Readmit 0-30], Total Records(Readmits))

Percent 31-60 = DIVIDE([Readmit 31-60], Total Records(Readmits))
 
Percent 61-90 = DIVIDE([Readmit 61-90], Total Records(Readmits))
 
Percent 91-365 = DIVIDE([Readmit 91-365], Total Records(Readmits))
 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!

Regards,

B Manikanteswara Reddy

 

View solution in original post

5 REPLIES 5
jambopriti
Helper I
Helper I

Thank you. I had a twik my table and column data type. it is working now. 

Thank you for your help!! I'll mark this one as solved. Thanks again.

jambopriti
Helper I
Helper I

Thanks. Need a guidance on the above. thanks.

Hi @jambopriti ,

 

Thank you for reaching out to Microsoft Fabric Community Forum.

Please use the following DAX measures.

 

Total Records(Readmits) = COUNTROWS('ReAdmit DATA')

 

Readmit 0-30 =
CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] >= 0,
    'ReAdmit DATA'[Days] <= 30
)
 
Readmit 31-60 =
if(ISBLANK(CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 30,
    'ReAdmit DATA'[Days] <= 60
)),0,cALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 30,
    'ReAdmit DATA'[Days] <= 60
))
 
 
Readmit 61-90 =
CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 60,
    'ReAdmit DATA'[Days] <= 90
)
 
Readmit 91-365 =
CALCULATE(
    COUNTROWS('ReAdmit DATA'),
    'ReAdmit DATA'[same_level] = "Yes",
    'ReAdmit DATA'[Days] > 90,
    'ReAdmit DATA'[Days] <= 365
)
 
 
Percent 0-30 = DIVIDE([Readmit 0-30], Total Records(Readmits))

Percent 31-60 = DIVIDE([Readmit 31-60], Total Records(Readmits))
 
Percent 61-90 = DIVIDE([Readmit 61-90], Total Records(Readmits))
 
Percent 91-365 = DIVIDE([Readmit 91-365], Total Records(Readmits))
 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!

Regards,

B Manikanteswara Reddy

 

Hello, Thank you.

I'm getting the below errors. Please guide. Thanks.

 

 

Hello @jambopriti ,

 

Could you please share the sample PBIX file with us?

Additionally, kindly let us know the specific context in which you are encountering the errors. Are the errors occurring when you drag the measures onto a visual, or are they present within the measures themselves?

Your clarification will help us assist you more effectively.

 

Regards,

B Manikanteswara Reddy

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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