cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vsslasd1
Helper II
Helper II

Get the Minimum value for a column

I have a PBI Query as follows: 

SELECTCOLUMNS(FILTER('WIP-S','WIP-S'[Period]<>"Current"), 
"Period",SELECTCOLUMNS(FILTER('WIP-S','WIP-S'[Period]<>"Current"), DateAdd(MIN('WIP-S'[Period])),-7,day),"Commission", 'WIP-S'[Commission],
"Current", 'WIP-S'[Current],
"I1", 'WIP-S'[I1],
"P1", VALUE('WIP-S'[P1]),
"P2", VALUE('WIP-S'[P2]),
"P0", 'WIP-S'[P0],
"P4", 'WIP-S'[P4],
"P5", 'WIP-S'[P5],
"SM", 'WIP-S'[SM],
"WIP", 'WIP-S'[WIP],
"Territory",'WIP-S'[Territory]),

This data is imported from another system. The "Period" Column is Text, and contains text and "text dates".

I'm having an issue with the following line:
I'm having difficulty with this line:

 

"Period",SELECTCOLUMNS(FILTER('WIP-S','WIP-S'[Period]<>"Current"), DateAdd(MIN('WIP-S'[Period])),-7,day),

I'd like to get the minimum value of that table with the filter criteria, and then subtract 7 days from that minimum value and ensure it is converted to a date value.

A close approximation to what I am trying to accomplish in TSQL would be:

Select
I1,
Period=(Select DateAdd(day,-7,Min(Convert(date,[Period])) from [WIP-S] where [Period]<>'Current'),
P1,
P2,
P3,
P4,
P5,
SM,
WIP,
Territory
From [WIP-S]


How would I replicate the TSQL above to accomlish the result in PowerBI Query? 


Thankyou. 

1 REPLY 1
HotChilli
Super User
Super User

We're going to have to do something about this - "The "Period" Column is Text, and contains text and "text dates"."

 

Can you post some sample data and give us your desired outcome please?

 

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!