Forum Discussion
How to split two values inside one column into two different measures?
Does someone know how I can split a measure just using DAX? I have a measure from my database with two values (value A and B), I want to create two seperate measures from that single measure. Measue A and Measure B, does someone know how to do this in DAX?
Example: measure X contains the values ABC and XYZ
I want to calculate the revenue for value ABC and XYZ and then also calculate the difference between them. Therefore I need ABC and XYZ in two seperate measures.
Anybody with a suggestion for this problem?
P.s. I'm working with a live connection, so I can't make changes into my database.
Gjakova , measure like ?
New York= calculate(sum(Table[revenue]),filter(table,table[city]="New York"))
Los Angeles= calculate(sum(Table[revenue]),filter(table,table[city]="Los Angeles"))diff = [New York] - [Los Angeles]
4 Replies
- amitchandakSuper User
Gjakova , what do mean by split here
there are so many functions to deal with text
https://docs.microsoft.com/en-us/dax/text-functions-dax
It needs to done on row context like
countx(table, if(left(Table[col],2) ="AB",Table[Val1],Table[Val2]))
sumx(table, if(left(Table[col],2) ="AB",Table[Val1],Table[Val2]))
- GjakovaPost Patron
Hi amitchandak thank you for your reply.
I think that measure is incorrect (?)
What I mean is this, I have a column that shows the following:
City New York Los Angeles And I have another column with revenue.
I want to create a measure which calculates all the revenue from New York and another measure which calculates the revenue from Los Angeles.
Furthermore, I would like to show the difference in revenue between New York and Los Angeles. But for that I could just use the measure of New York minus the measure of Los Angeles.
But I can't get the first two measures to work, but in my mind I think it should be very simple, but I can't figure it out why it does not work.
- amitchandakSuper User
Gjakova , measure like ?
New York= calculate(sum(Table[revenue]),filter(table,table[city]="New York"))
Los Angeles= calculate(sum(Table[revenue]),filter(table,table[city]="Los Angeles"))diff = [New York] - [Los Angeles]