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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DAX query for the below request

jpatel_0-1633362389227.png

Hello community,

 

My data is something like above where a company belongs to different Sides based on the projects. Every project has a start date and project active date.

 

I want to calculate the number of sides for a company between start date and project active date and based on that want to calculate how many companies at a particular time between start date and project active date belong to which category.

 

Category based on number of sides ::: count (1) = burger, count(2)= burger+fries, count(3)=happy meal 

 

For example,

Mcdonalds has 3 sides : MS, PS and SD and 3 projects : A, B and C.

jpatel_1-1633362736349.png

Mcdonalds will be active from 2017-08-11 to 2022-08-01

Now, from (startdate)2017-08-11 to 2018-01-09 it had one side MS project A so Burger category and from 2018-01-10 one more project C was added so Burger+fries till 2019-08-01 when project B was added so now its an happy meal but now we also have to include project active date of projects while counting the number of sides.

All projects are active but on 2021-01-10 we loose 1 so now it is 2=burger+fries again on 2021-08-11 we loose one more = burger and this burger will stay active till 2022-08-01.

 

This is just one client, MCD but in one visual I have to show for all clients at a particular time how many companies are in which category.

 

Something like below:

jpatel_5-1633363238909.png

I have also attached the pbix file with the message.

 

Appreciate your help.

 

Thank you

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Like this?

AlexisOlson_0-1633365303378.png

To get this, I converted the date columns from text to date data type, created a new calculated table DimDate using CALENDARAUTO() and defined the following measure:

CountSides =
VAR SelectedDate = MAX ( DimDate[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Sample'[Sides] ),
        'Sample'[EndDate] >= SelectedDate,
        'Sample'[StartDate] < SelectedDate
    )

 

View solution in original post

8 REPLIES 8
AlexisOlson
Super User
Super User

Like this?

AlexisOlson_0-1633365303378.png

To get this, I converted the date columns from text to date data type, created a new calculated table DimDate using CALENDARAUTO() and defined the following measure:

CountSides =
VAR SelectedDate = MAX ( DimDate[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Sample'[Sides] ),
        'Sample'[EndDate] >= SelectedDate,
        'Sample'[StartDate] < SelectedDate
    )

 

Anonymous
Not applicable

Thanks Alexis 😊 You are awesome. Solution worked for me

Anonymous
Not applicable

This helps but what I exactly want is a measure based on count of sides : 1(Burger),2(burger+fries),3(happy meal) and 4(happy meal+nuggets) and then show the count of companies that belong to different category at a time

Like this?

AlexisOlson_0-1633444399093.png

 

For this, I created a new table Sides with a single column Count with values 1 through 4 and a new measure

CompanyCount = 
VAR SideCount = SELECTEDVALUE ( Sides[Count] )
RETURN
    SUMX ( VALUES ( 'Sample'[Company] ), IF ( [CountSides] = SideCount, 1 ) )
smpa01
Super User
Super User

@Anonymous  please attache the pbix

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  doesn't work

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.