cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Surya1
Helper I
Helper I

Help needed urgently DAX

I have a table

Table
Col A Col B Col C
A. 1. 4/4/2018
A. 0. 4/4/2018
A. 2. 5/4/2018
A. 0. 6/4/2018
B. 2. 4/4/2018
B. 1. 5/4/2018
C. 0. 4/4/2018
C. 0. 6/4/2018
C. 1. 7/4/2018
D. 1. 7/4/2018

A date slicer having start date end date is applied on this table using a calendar table with date column having a relationship with the col C.I want to create a measure which sum the value of colb for the dates selected in the slicer under a particular col A.
If the slicer values are 4/4/2018 to 6/4/2018
A 3
B. 3
C 0

Also another measure,if the value of above measure is 0 then 0,if it is 1 then 1 if it is greater than 1 then 2

Can someone please help me.needed urgently
1 ACCEPTED SOLUTION
v-xjiin-msft
Solution Sage
Solution Sage

Hi @Surya1

 

Please try following measures:

 

SUM ColB =
CALCULATE (
    SUM ( TableName[Col B] ),
    FILTER (
        ALLSELECTED ( TableName ),
        TableName[Col A] = MAX ( TableName[Col A] )
    )
)
Result =
IF (
    ISBLANK ( [SUM ColB] ),
    BLANK (),
    IF ( [SUM ColB] = 0, 0, IF ( [SUM ColB] = 1, 1, IF ( [SUM ColB] > 1, 2 ) ) )
)

 

 1.PNG

 

Thanks,
Xi Jin.

View solution in original post

1 REPLY 1
v-xjiin-msft
Solution Sage
Solution Sage

Hi @Surya1

 

Please try following measures:

 

SUM ColB =
CALCULATE (
    SUM ( TableName[Col B] ),
    FILTER (
        ALLSELECTED ( TableName ),
        TableName[Col A] = MAX ( TableName[Col A] )
    )
)
Result =
IF (
    ISBLANK ( [SUM ColB] ),
    BLANK (),
    IF ( [SUM ColB] = 0, 0, IF ( [SUM ColB] = 1, 1, IF ( [SUM ColB] > 1, 2 ) ) )
)

 

 1.PNG

 

Thanks,
Xi Jin.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors