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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
rachelb123
Helper I
Helper I

Using different calculations based on Column Value with switch/if loop

I am trying to find usage rate = number of days used in quarter/total days in quarter for 5 tools. Some have a different specification for this calculation as stated below:

Tool A,B,C = number of days used/ total working days in quarter

Tool D & E = If used even once a quarter then 100% if no lines present with this toolname then 0% 

Here is the main table - UsageRateTable

ToolNameUserNameUserEmailUseDate

A

user1n7/1/2025
Auser3n7/2/2025
Buser2n7/1/2025
Cuser3n7/1/2025
Buser1n7/2/2025
Auser2n7/3/2025
Cuser3n7/4/2025
Cuser2n7/4/2025

D

user 1n7/2/2025
Duser 1n7/4/2025
Buser2n7/1/2025

And I would like to calculate usage rate with the formula = (days the app was used/total number of days in a quarter)*100.

Usage Rate for Tool A =  3/63

Usage Rate for B = 2/63

Usage Rate for C = 2/63

Usage Rate for D = 100%

Usaged Rate for E = 0%

This is how I currently calculate before Tool D and E were added: 

Measure :

Usage Days = DISTINCTCOUNT('Usage RateOpEx'[UseDate])
Usage Rate (%) = 'UsageRateTable'[Usage Days]/64
There were my tries --
AnotherUsage = IF('Usage RateOpEx'[ToolName] = "D" || 'Usage RateOpEx'[ToolName] = "E", 'UsageRateTable'[Usage Days]/1, 'UsageRateTable'[Usage Days]/64)
 
TestUsage = SWITCH(TRUE,'UsageRateTable'[Usage Days] = "Cycle Time Analysis Tool" ,'UsageRateTable'[Usage Days]/1,'Usage RateTable'[Usage Days] = "Cycle Time Risk Report DRC", 'Usage RateTable'[Usage Days]/1, 'Usage RateTable'[Usage Days]/64 )
 
I'm not sure how to do this by seperating out tools I keep getting no results. Thanks in advance for any help you can offer.
1 ACCEPTED SOLUTION

Hi @rachelb123,

Thank you for clarification.

you can follow below approach.

create tool dimenssion table 

ToolList =
DATATABLE(
"ToolName", STRING,
{
{"A"},
{"B"},
{"C"},
{"D"},
{"E"}
}
)

Create Relationship

  • Relate ToolList[ToolName]UsageRateTable[ToolName].

  • Use ToolList[ToolName] in your matrix (instead of from UsageRateTable).

Now write below measure 

TotalWorkingDays = 63 // or dynamic from a calendar table later

Usage Rate (%) =
VAR _tool = SELECTEDVALUE('ToolList'[ToolName])
VAR _usageDays =
CALCULATE(
DISTINCTCOUNT('UsageRateTable'[UseDate]),
KEEPFILTERS(VALUES('ToolList'[ToolName]))
)
RETURN
SWITCH(
TRUE(),
_tool IN {"D","E"}, IF(_usageDays > 0, 1, 0),
DIVIDE(_usageDays, [TotalWorkingDays], 0)
) * 100

 

View solution in original post

7 REPLIES 7
Shahid12523
Community Champion
Community Champion

Usage Rate (%) =
VAR Tool = SELECTEDVALUE(UsageRateTable[ToolName])
VAR DaysUsed = CALCULATE(DISTINCTCOUNT(UsageRateTable[UseDate]), UsageRateTable[ToolName] = Tool)
VAR UsedOnce = CALCULATE(COUNTROWS(UsageRateTable), UsageRateTable[ToolName] = Tool)
RETURN
SWITCH(
TRUE(),
Tool IN {"A", "B", "C"}, DIVIDE(DaysUsed, 63) * 100,
Tool IN {"D", "E"}, IF(UsedOnce > 0, 100, 0),
BLANK()
)


This handles all five tools with correct logic—A/B/C by usage days, D/E as binary flags. Clean, scalable, and ready for matrix visuals.

Shahed Shaikh

@Shahid12523 Thank you for your response. In this solution if the data isn't present then it needs to be 0% but in your solution it removes the entire toolname from the matrix. 

FBergamaschi
Super User
Super User

Hi @rachelb123,

Just to be sure: 

1 test usage, usage rate etc you mention in your post are just different attempato to solve the sane issue?

2 why the 64 at the denominator? Should not that be the nr of days of the quarter? Which might or not be 64 if we speaker about working days...

3 we are speaking about a measure or a column to create in DAX? I assume a measure but pls confirm

 

Finally, can you show an image of the visual you want to apply this thing to?

 

Thanks

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Hi @FBergamaschi,

1. Usage Days and Usage Rate are the original measure I used before Tool D and E were added to my dashboard. This worked because all the tools in the original table just used the basic formula stated above but now with this new addition there is a new way to calculate those. The Another Usage and Test Usage  is my attempt at trying to include tool D and E into the calculation. They are both measures.

2. It is 64 because it excludes weekends and holidays. 

3. Im very new at PowerBI and I dont know if having it as a measure/column is easier. Due to personal data I can't share a screenshot but this is what I want the matrix to look like- 

ToolNameUsage Rate (%)
A4.76%
B3.17%
C3.17%
D100%
E0%
grazitti_sapna
Super User
Super User

Hi @rachelb123,

 

You should create a separate calendar table and mark working days. But since you already mentioned 63 or 64 days, we can hardcode for now:

TotalWorkingDays = 63 // replace with dynamic calc if needed

 

Now Create a measure

 

Usage Rate (%) =
VAR _tool = SELECTEDVALUE('UsageRateTable'[ToolName])
VAR _usageDays = CALCULATE(
DISTINCTCOUNT('UsageRateTable'[UseDate]),
ALLEXCEPT('UsageRateTable', 'UsageRateTable'[ToolName])
)
RETURN
SWITCH(
TRUE(),
_tool IN {"D","E"},
IF(_usageDays > 0, 1, 0), -- 100% if used once, else 0%
DIVIDE(_usageDays, 63, 0) -- normal calc for A, B, C
) * 100

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

Hi @grazitti_sapna, Thank you for your response, In the solution if the tool was never used it won't show up in the data but in the table it should still show as 0% since it wasn't present but your solution removes that tool altogether in the matrix.

Hi @rachelb123,

Thank you for clarification.

you can follow below approach.

create tool dimenssion table 

ToolList =
DATATABLE(
"ToolName", STRING,
{
{"A"},
{"B"},
{"C"},
{"D"},
{"E"}
}
)

Create Relationship

  • Relate ToolList[ToolName]UsageRateTable[ToolName].

  • Use ToolList[ToolName] in your matrix (instead of from UsageRateTable).

Now write below measure 

TotalWorkingDays = 63 // or dynamic from a calendar table later

Usage Rate (%) =
VAR _tool = SELECTEDVALUE('ToolList'[ToolName])
VAR _usageDays =
CALCULATE(
DISTINCTCOUNT('UsageRateTable'[UseDate]),
KEEPFILTERS(VALUES('ToolList'[ToolName]))
)
RETURN
SWITCH(
TRUE(),
_tool IN {"D","E"}, IF(_usageDays > 0, 1, 0),
DIVIDE(_usageDays, [TotalWorkingDays], 0)
) * 100

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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