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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
xiumi_hou
Post Partisan
Post Partisan

Urgent! Question of dax switch fuction

Dear alL,

 

I want to create a table,

 

The first column is 1,2,3,4,

The second column is my switch funtion according to 1,2,3,4

(Second column is data type is percentage)

 

I have my measure 1,2,3,4, and I want to return the percentage of each. Ex. 1/(1+2+3+4)

However, when I put the two columns together, the percentage all show 100%...

Anyone know how I can adjust it? Thank you 

1 ACCEPTED SOLUTION

Hi @xiumi_hou 

Create a date table without relationship with others,

Capture15.JPG

Add "date" column from this "date" table to a slicer,

Create measures

Capture14.JPG

mindate = MIN('date'[Date])

maxdate = MAX('date'[Date])

all in period = CALCULATE(COUNT('Table'[id]),FILTER(ALLSELECTED('Table'),'Table'[closed date]<=[maxdate]&&'Table'[closed date]>=[mindate]))

per reason =
CALCULATE (
    COUNT ( 'Table'[id] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[close reason] = MAX ( 'Table'[close reason] )
            && 'Table'[closed date] <> BLANK ()
            && 'Table'[closed date] <= [maxdate]
            && 'Table'[closed date] >= [mindate]
    )
)


percentage = [per reason]/[all in period]

modified % = IF(HASONEVALUE('Table'[close reason]),[percentage],SUMX(ALL('Table'[close reason]),[percentage]))

Best Regards
Maggie
Community Support Team _ Maggie Li
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

8 REPLIES 8
edhans
Super User
Super User

Can you post a sample of your data and what the expected result is? I cannot tell what is in your second column. You said it is a switch function, a percentage, and them mention a measure, and measures don't go in columns, so I am not sure what your data set looks like.

 

See this article on what you need to post to help us help you get a good answer.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi Please see my measure:

 

I have three table. 

1,Case table with column  case ID/received date/ closed date./closed reason(I have a,b,c,d total for four clousre reason) 

* Some of the case not closed yet, so no closed date and closure reason

2,Date table (My filter for this entire report is using date table), the connection of the table is received date with date table

 

I want to create a table like this: 

When I select Dec1-Dec 31, I want to show percentage of closed case by closure reason (the closed date should within period)

Column 1(close reason)    Column 2(Percentage of each closure reason)

a                                        20%

b                                        30%

c                                         20%

d                                         30%

Total                                  100%

 

Can you help me build the function? Thank you  @edhans 

If you create a graph close by reason. Then you can % of total from by right click at the measure in visual. Now how to have close date and receive date refer my blog on a similar line

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Screenshot 2020-01-13 09.54.44.pngScreenshot 2020-01-13 09.54.50.png

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak  If it's a table.....what should I do? When I put all the percentage into one table.... all of it show 100% for a/b/c/d..Thank you 

Hi @xiumi_hou 

Create a date table without relationship with others,

Capture15.JPG

Add "date" column from this "date" table to a slicer,

Create measures

Capture14.JPG

mindate = MIN('date'[Date])

maxdate = MAX('date'[Date])

all in period = CALCULATE(COUNT('Table'[id]),FILTER(ALLSELECTED('Table'),'Table'[closed date]<=[maxdate]&&'Table'[closed date]>=[mindate]))

per reason =
CALCULATE (
    COUNT ( 'Table'[id] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[close reason] = MAX ( 'Table'[close reason] )
            && 'Table'[closed date] <> BLANK ()
            && 'Table'[closed date] <= [maxdate]
            && 'Table'[closed date] >= [mindate]
    )
)


percentage = [per reason]/[all in period]

modified % = IF(HASONEVALUE('Table'[close reason]),[percentage],SUMX(ALL('Table'[close reason]),[percentage]))

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Can you provide the formula for close formula. Because you have receive date for case receive and there are open . So what is close %. and are you looking for % of Total ?

 

 

To deal with these kind of case, I have one blog

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

The information you have provided is not making the problem clear to me. Can you please explain with an example. If possible please share a sample pbix file after removing sensitive information.
Thanks.

My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Please see my measure:

 

I have three table. 

1,Case table with column  case ID/received date/ closed date./closed reason(I have a,b,c,d total for four clousre reason) 

* Some of the case not closed yet, so no closed date and closure reason

2,Date table (My filter for this entire report is using date table), the connection of the table is received date with date table

 

I want to create a table like this: 

When I select Dec1-Dec 31, I want to show percentage of closed case by closure reason (the closed date should within period)

Column 1(close reason)    Column 2(Percentage of each closure reason)

a                                        20%

b                                        30%

c                                         20%

d                                         30%

Total                                  100%

 

Can you help me build the function? Thank you  @amitchandak 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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