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
Dain
Frequent Visitor

Need help with DAX

Hello All. I am glad to be part of this community am new to powerbi.i hope I could learn more with the help of all here.am struggling with a logic here.
I have a table

Date. Group Value
1/4/2018. A. 1
1/4/2018. B. 2
1/4/2018. C. 0
2/4/2018. A. 2
2/4/2018. B. 1
2/4/2018. C. 1
3/4/2018. A. 0
3/4/2018. B. 2
3/4/2018. C. 1

I have a date slicer with start n end dates..Wen a user selects a date period in the slicer I want the value field to b summed group vice for that selected period n if that summed value is 0 ,then the measure should return 0,if 1 ,then 1 n greater than 1 then 2.

If the slicer start n end dates are

1/4/2018 2/4/2018

Group Sum. Output
A. 3. 2
B. 3. 2
C. 1. 1

I want to display the output in a visual
Can someone help me with the DAX
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Dain,

 

Use the following measure:

 

Output = SWITCH(SUM(Groups[Value]); 0; 0 ; 1 ; 1 ; 2)

Result is as below:

group.gif

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @Dain,

 

Use the following measure:

 

Output = SWITCH(SUM(Groups[Value]); 0; 0 ; 1 ; 1 ; 2)

Result is as below:

group.gif

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Dain
Frequent Visitor

Hi All.I am new to powerBI nad new to this community.I am struggling with a logic to get it implemented in DAX.
Here comes my logic
I have a table

date    group    value
1/4/2018  A         2
1/4/2018  B         0
1/4/2018  C         1
2/4/2018  A         1
2/4/2018  B         1
2/4/2018  C         2
3/4/2018  A         0
3/4/2018  B         2
3/4/2018  C         2

I have a date slicer with start n end dates in the report.For the dates selected in the slicer i want to calculate the sum
of values for each group for that period.Also i wnat to generalize the sum that is if 0 then 0,if 1 then 1 if greater than 1 Then 2.

If the dates selected :1/4/2018  to 2/4/2018
then the output should be

group    value   output

A           3      2
B           1      1
C           3      2

 

 

Kindly help please..  Thanks.

waltheed
Solution Supplier
Solution Supplier

This is what I figured out. Is this what you mean?

 

The sum of value by group goes automatically.

The logic you mentioned can be described as:

 

output = if(sum([value]) >1 ,2;sum([value]))

 

 

Capture.PNG

 

Hope this helps. 

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

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.