Forum Discussion

Eureka0206's avatar
Eureka0206
New Member
4 years ago
Solved

IFs, or Switch - Data Aggregation

Hi Guys,

 

First i will start by saying im new to Power BI and come from a mainly excel background, so yes, im sure im doing this wrong!!

 

I'm trying to work on a dashboard for a department that deals with enquiries. They have a current KPI that records length of time taken to complete and enquiry. This is currently measured in 0,1,2,3 and 3+ days.

 

I have created a column that calculates the days to close.

 

Days to Close = if(ISBLANK(DataD[Date Completed]),BLANK(),DataD[Date Completed] - DataD[Date Issued by OS])
 
So if its not completed the Days to close is blank, but due to the dates given on date completed and  date issued by os, the resulting days range from -365+ to +600
 
I want to create a new column that aggregates the dates in DataD[Days to close] into blank, 0,1,2,3 and 3+
 
I have tried nested IF functions, as i would in excel but i keep getting errors.
 
Would anyone be able to give me some advice or guidance on how to do this in Power BI?
 
 
  • Hi,

    For multiple IF structure similar to excel you can use SWITCH + TRUE combination. The basic structure is as follows:
    NestedLogic = SWITCH(TRUE(),
    "Condition 1", "Result 1",
    "Condition 2", "Result2")

    Typically in these kinds of categorization cases I would use measure for efficency, but a calculated column works all the same. 

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!


2 Replies

  • ValtteriN's avatar
    ValtteriN
    Community Champion

    Hi,

    For multiple IF structure similar to excel you can use SWITCH + TRUE combination. The basic structure is as follows:
    NestedLogic = SWITCH(TRUE(),
    "Condition 1", "Result 1",
    "Condition 2", "Result2")

    Typically in these kinds of categorization cases I would use measure for efficency, but a calculated column works all the same. 

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!