Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX Measure

I have Project Table, some necessary columns are given below:

Project CaseOrganizationStartPeriodEndPeriod
42251XYZ8/27/201710/16/2017

 

I have another table Tickets, which looks like below:

CaseOrganizationStartPeriodEndPeriod
52454XYZ8/29/20179/10/2017
56464XYZ11/16/201712/12/2017
54859XYZ11/19/201712/12/2017
52421XYZ1/9/20182/2/2018


I want to create separate measures for the below:
1) Case in Tickets table created between the StartPeriod and EndPeriod of Project Case.
2) Case in Tickets table create during the first 30 days after the EndPeriod of Project Case.

Any help 

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Anonymous  so as I understand, Measure1 is working as intended but Measure2 is not with the revised dataset.

 

Try this out

 

Measure2 =
VAR _0 =
    CALCULATE (
        MAX ( Project[EndPeriod] ),
        FILTER (
            VALUES ( Project[Organization] ),
            Project[Organization] = CALCULATE ( MAX ( Tickets[Organization] ) )
        )
    )
VAR _1 =
    CALCULATE (
        COUNT ( Tickets[Case] ),
        FILTER ( Tickets, Tickets[StartPeriod] > _0 && Tickets[StartPeriod] <= _0 + 30 )
    )
RETURN
    _1

 

smpa01_0-1633451140784.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

6 REPLIES 6
smpa01
Super User
Super User

@Anonymous  so as I understand, Measure1 is working as intended but Measure2 is not with the revised dataset.

 

Try this out

 

Measure2 =
VAR _0 =
    CALCULATE (
        MAX ( Project[EndPeriod] ),
        FILTER (
            VALUES ( Project[Organization] ),
            Project[Organization] = CALCULATE ( MAX ( Tickets[Organization] ) )
        )
    )
VAR _1 =
    CALCULATE (
        COUNT ( Tickets[Case] ),
        FILTER ( Tickets, Tickets[StartPeriod] > _0 && Tickets[StartPeriod] <= _0 + 30 )
    )
RETURN
    _1

 

smpa01_0-1633451140784.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

@smpa01 This worked well! Thanks
Instead of Count I just used Distinctcount, as there were duplicates in my data. Just wanted to update if anyone refers to this solution.

smpa01
Super User
Super User

@Anonymous 

 

Measure1 = 
CALCULATE (
    COUNT ( Tickets[Case] ),
    FILTER (
        Tickets,
        Tickets[StartPeriod] >= MAX ( Project[StartPeriod] )
            && Tickets[StartPeriod] <= MAX ( Project[EndPeriod] )
    )
)

Measure2 = 
CALCULATE (
    COUNT ( Tickets[Case] ),
    FILTER (
        Tickets,
         Tickets[StartPeriod] <= MAX ( Project[EndPeriod] )+30
    )
)
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

@smpa01 For Measure 2, I am not getting correct results.
Every Organization Starts with a Project Case, it may last upto N number of days depending upon how long it took.
But I need to know the Cases submitted in the First 30 days when the Project Case got Closed(EndDate)
For Ex: If Project Case took the Entire August Month to complete and get Closed(8/31/2021). I need to know the Cases submitted in the Month of September (30 days).

@Anonymous  my solutuion was based on the data provided.

 

Improve your question with better sample data if you are not getting the result you desire.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

@smpa01 I just updated the dates for the case
Project Table

Project caseOrganizationStartPeriodEndPeriod
42251XYZ8/6/20178/31/2017


Tickets Table

Case OrganizationStartPeriodEndPeriod
52454XYZ8/28/20179/6/2017
56464XYZ9/6/20179/18/2017
54859XYZ9/7/20179/26/2017
52421XYZ9/8/20179/9/2017


Here, when you look at the dates. The project case for Organization XYZ was started and completed in August on 8/31/2017.

For Measure 2, I want the cases from Tickets Table where the StartPeriod is after 8/31/2017 for first 30 days (i.e from 9/1/2017 to 9/30/2017)
Makes Sense?

Any recommendations @Greg_Deckler @amitchandak 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.