Forum Discussion
DAX
- 6 years ago
Hi Sujit_Thakur ,
Do you want to count the number of Model or the number of Name?
We can create two measures and use the following ways to meet your requirement.
1. Create a Model column in data table.
Model = CALCULATE(MAX('index table'[Model]),FILTER('index table','index table'[Name]='data table'[Name]))2. Create a new table.
Table = CROSSJOIN(VALUES('index table'[Model]),{"<0.25","0.25-0.5","0.5-0.75",">0.75","Total"})3. If you want to count the number of Name, you can use the following measure.
Measure = var _025 = CALCULATE(COUNT('data table'[Name]),FILTER('data table',[Test]<0.25 && 'data table'[Model]=MAX('Table'[Model]))) var _025_05 = CALCULATE(COUNT('data table'[Name]),FILTER('data table',[Test]>=0.25&&[Test]<0.5 && 'data table'[Model]=MAX('Table'[Model]))) var _05_075 = CALCULATE(COUNT('data table'[Name]),FILTER('data table',[Test]>=0.5&&[Test]<0.75 && 'data table'[Model]=MAX('Table'[Model]))) var _075 = CALCULATE(COUNT('data table'[Name]),FILTER('data table',[Test]>=0.75&& 'data table'[Model]=MAX('Table'[Model]))) return SWITCH( TRUE(), MAX('Table'[Value]) = "<0.25",_025, MAX('Table'[Value]) = "0.25-0.5",_025_05, MAX('Table'[Value]) = "0.5-0.75",_05_075, MAX('Table'[Value]) = ">0.75",_075, MAX('Table'[Value]) = "Total",_025+_025_05+_05_075+_075)4. If you want to count the number of Model, you can use the following measure.
Measure 2 = var _025 = CALCULATE(DISTINCTCOUNT('data table'[Model]),FILTER('data table',[Test]<0.25 && 'data table'[Model]=MAX('Table'[Model]))) var _025_05 = CALCULATE(DISTINCTCOUNT('data table'[Model]),FILTER('data table',[Test]>=0.25&&[Test]<0.5 && 'data table'[Model]=MAX('Table'[Model]))) var _05_075 = CALCULATE(DISTINCTCOUNT('data table'[Model]),FILTER('data table',[Test]>=0.5&&[Test]<0.75 && 'data table'[Model]=MAX('Table'[Model]))) var _075 = CALCULATE(DISTINCTCOUNT('data table'[Model]),FILTER('data table',[Test]>=0.75&& 'data table'[Model]=MAX('Table'[Model]))) return SWITCH( TRUE(), MAX('Table'[Value]) = "<0.25",_025, MAX('Table'[Value]) = "0.25-0.5",_025_05, MAX('Table'[Value]) = "0.5-0.75",_05_075, MAX('Table'[Value]) = ">0.75",_075, MAX('Table'[Value]) = "Total",_025+_025_05+_05_075+_075)The SWITCH function means that when the current column is equal to a certain value, output the corresponding value.
For example, when Table[Value] = “<0.25”, then output the value conforming to <0.25.
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
Dear Arklur ,
Is there any way of getting an output as an table using DAX ?
I have dax studio installed on my system , I read somewhere that I can use evaluate using DAX studio
Hi Sujit_Thakur ,
EVALUATE is not available as a DAX function in POwer BI.
When you tallk about EVALUATE in DAX Studio tool, it just serves as a starting query variable to write a dax expresion within it for dax studio tool to execute it.
In DAX studio tool, a DAX expression is identified within EVALUATE clause. So, EVALUATE is just a clause used to write your dax expression in this tool. It's just an statement needed to execute a query within this tool.
You can read in detail here: https://dax.guide/st/evaluate/
Thanks,
Pragati
- Sujit_Thakur6 years agoSolution Sage
Pragati11 can calculate table be used here in any way?
- Pragati116 years agoSuper User
Hi Sujit_Thakur ,
I don't think this will help.
Try looking at Segmentation as suggested by amitchandak
There is a link for this as well for an existing thread on this:
Thanks,
Pragati