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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Get help building a comparison measure

Hello all,

 

I want to compare sales included in Current Quarter depending on the Closed or Open date, see the table below

 

Compared by Quarter Sale Logic.PNG

So with this measure the goal is to calculate the maturity of each sale or how much time each sale takes to be closed if it's included on the Quarter. Any help would be really appreciated, thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please correct me if I wrongly understood your question.

Firstly, matrix does not support sub header, if you want to return the datediff in matrix visual, that is not feasible .

My suggestion is to create 4 measures to return the datediff in table visual .

(1)I create two tables, duration data and Qty, like this

Ailsa-msft_0-1618365463318.png

Ailsa-msft_1-1618365463319.png

(2)Use IF dax to create 4 measures to return the datediff .

1Q = IF(MAX('duration date'[Closed date])<MAX(Qty[1Q]) || MAX('duration date'[Open date])>MAX(Qty[1Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[1Q]),DAY))

2Q = IF(MAX('duration date'[Closed date])<MAX(Qty[2Q]) || MAX('duration date'[Open date])>MAX(Qty[2Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[2Q]),DAY))

3Q = IF(MAX('duration date'[Closed date])<MAX(Qty[3Q]) || MAX('duration date'[Open date])>MAX(Qty[3Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[3Q]),DAY))

4Q = IF(MAX('duration date'[Closed date])<MAX(Qty[4Q]) || MAX('duration date'[Open date])>MAX(Qty[4Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[4Q]),DAY))

 

The effect is as shown:

Ailsa-msft_2-1618365463322.png

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

Please correct me if I wrongly understood your question.

Firstly, matrix does not support sub header, if you want to return the datediff in matrix visual, that is not feasible .

My suggestion is to create 4 measures to return the datediff in table visual .

(1)I create two tables, duration data and Qty, like this

Ailsa-msft_0-1618365463318.png

Ailsa-msft_1-1618365463319.png

(2)Use IF dax to create 4 measures to return the datediff .

1Q = IF(MAX('duration date'[Closed date])<MAX(Qty[1Q]) || MAX('duration date'[Open date])>MAX(Qty[1Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[1Q]),DAY))

2Q = IF(MAX('duration date'[Closed date])<MAX(Qty[2Q]) || MAX('duration date'[Open date])>MAX(Qty[2Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[2Q]),DAY))

3Q = IF(MAX('duration date'[Closed date])<MAX(Qty[3Q]) || MAX('duration date'[Open date])>MAX(Qty[3Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[3Q]),DAY))

4Q = IF(MAX('duration date'[Closed date])<MAX(Qty[4Q]) || MAX('duration date'[Open date])>MAX(Qty[4Q]),"Exclude",DATEDIFF(MAX('duration date'[Open date]),MAX(Qty[4Q]),DAY))

 

The effect is as shown:

Ailsa-msft_2-1618365463322.png

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you sooo much, this totally worked 🙂

amitchandak
Super User
Super User

@Anonymous , not very clear, Refer this blog

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

 

And the file attached for Open items between date and comparison

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks so much, however I need to exclude whenever:

"Open Date" is < "Reference Date"

or

"Closed Date" >"Reference Date"

Your input is much appreciated 

 

Thanks

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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