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
p-ha
Frequent Visitor

DAX to add a column to an existing table, assign category based on other column's data

Hi, I have the sample table as follow. 

 

Invoice #Days LateDays Late Bucket
A15<=5 days
A210>5 days
A31<=5 days
A410>5 days
A50<=5 days
A65<=5 days

 

Invoice # and Days Late are the 2 Data Columns exist on table, I do not have the Days Late Bucket Column and I'd like to add this to the table to assign the category of late bucket based on the condition of "Days Late". I can't do this via Query Editor as the datas are pulled via Analytic Services. Is there a Dax to achieve my purpose? 

 

Ultimately I want to count the Invoices that associated to each Days Late Bucket. The analytic services have already created the Measure to calculate the invoice count for each Days Late, but not per Days Late Bucket.

 

In sum, current state: I can have a count table of:

Days Late - Count

0 - 1

1 - 1

5 - 2

10 - 2

 

I want to have a future table to show:

Days Late bucket - Count

<= 5 days - 4 

> 5 days - 2

 

Thank you in advance for your help!!

P.Ha

1 ACCEPTED SOLUTION

Yeah, you can't use measures the way you can a table column (e.g. on a graph axis or as pie chart category) but you can at least use them in a matrix visual or a bar chart reasonably.

View solution in original post

5 REPLIES 5
AlexisOlson
Super User
Super User

You can't modify tables if you're connected to an analysis server (not import but connected live).

 

In this case, a workaround might be to construct two measures, [<= 5 days] and [> 5 days] along these lines:

 

 

CALCULATE ( [InvoiceCountMeasure], Table1[Days Late] <=5 )

 

Thanks @AlexisOlson! If I go with the 2 measures, I won't be able to display them in a pie chart or a table Graph right? My folks want to show for example : bucket < 5 days late X% and bucket > 5 days late Y% on a pie chart, but I can't see it can be achieved if I were to create 2 measures. Am I understanding it correctly?

Yeah, you can't use measures the way you can a table column (e.g. on a graph axis or as pie chart category) but you can at least use them in a matrix visual or a bar chart reasonably.

lbendlin
Super User
Super User

This is in import mode, right?  In that case you can add a calculated column with a switch statement, or you can create a group in the Power BI UI.

 

p-ha
Frequent Visitor

Thanks @lbendlin ! unfortunately this is a Connect Live datas.

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.

Top Solution Authors